Jump to content


Photo

Knockout observable


  • Please log in to reply
1 reply to this topic

#1 rdevine

rdevine
  • Members
  • 12 posts

Posted 06 October 2017 - 09:07 PM

I've been experimenting with KnockoutJS and it's going pretty well but I'd like to improve the syntax involving observables. I've got my observable wrapper like this:

JObservable = class external 'ko.observable'
public
    constructor Create(initialValue: string); overload;
    constructor Create(initialValue: float); overload;
    constructor Create(initialValue: integer); overload;
    constructor Create(initialValue: variant); overload;
end;
In JS I can set an observable's value using syntax like myObservable('New String') but it's not obvious how to get syntax like this using an SMS class - and I suspect it's not currently possible. If it's not, it would be a nice one for Eric to add.

#2 Laksekjønn

Laksekjønn
  • Members
  • 455 posts

Posted 07 October 2017 - 03:55 PM

The knockout library has a definition typescript file containing all interfaces, for instance, you can get the code at https://gist.github.com/3833509 and use the nice tool created by Christian Budde called t2pas @https://github.com/CWBudde/ts2pas, this is a node tool to convert TypeScript definition files to smart pascal object headers. The produced external interfaces output often has to be post processed manually, but in the end you have code completion.

BTW, In the new RTL > 2.3, TVariant have a lot of new members. Two that stands out as important: watch() and unwatch().
  • Dennis07 likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users