Created
April 28, 2015 06:24
-
-
Save ovcharik/15a3d40f2da61a0cc9d4 to your computer and use it in GitHub Desktop.
Reactive property mixin for meteor
This file contains 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
@PropertyMixin = | |
property: (prop, options) -> | |
Object.defineProperty @prototype, prop, options | |
reactiveProperty: (name) -> | |
@property name, | |
get: -> | |
dep = @["_#{name}_dep"] ?= new Tracker.Dependency | |
dep.depend() | |
@["_#{name}"] | |
set: (v) -> | |
dep = @["_#{name}_dep"] ?= new Tracker.Dependency | |
@["_#{name}"] = v | |
dep.changed() | |
v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment