Last active
January 9, 2018 17:35
-
-
Save codler/c91bc144a822c3fb0fc2 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