-
-
Save alibenmessaoud/e948bbdc3b06a6e1e3d0a4cf92f68a9f to your computer and use it in GitHub Desktop.
Ractive.extend options as TypeScript Class - http://jsfiddle.net/qnjgsq1L/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function RactiveExtendTypeScriptClass(tsClass: any): RactiveStatic { | |
| var instance = new tsClass(); | |
| var r = {}; | |
| for (var key in instance) { | |
| r[key] = instance[key]; | |
| } | |
| return Ractive.extend(r); | |
| } | |
| interface RactiveComponentPlugins { | |
| Animal: RactiveStatic; | |
| } | |
| class Animal implements RactiveExtendOptions { | |
| data = { | |
| key: "value" | |
| }; | |
| init(options: RactiveExtendOptions) { | |
| var self: Ractive = <any>this; | |
| self.add('a'); | |
| console.log('init'); | |
| console.log(options); | |
| } | |
| } | |
| Ractive.components.Animal = RactiveExtendTypeScriptClass(Animal); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment