Jump to content
Sign in to follow this  
rdevine

Knockout observable

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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().

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×