@cerebral/fluent
Advanced tools
Comparing version 1.0.0-1518821845306 to 1.0.0-1518858486644
@@ -128,2 +128,28 @@ /* eslint-env mocha */ | ||
}); | ||
it('should allow getters', () => { | ||
const Sequence = SequenceFactory(); | ||
const signal = Sequence((s) => s.action(function test({ state }) { | ||
state.foo = 'bar2'; | ||
})); | ||
let hasUpdated = 0; | ||
const rootModule = Module({ | ||
state: { | ||
foo: 'bar', | ||
get test() { | ||
return this.foo.toUpperCase(); | ||
} | ||
}, | ||
signals: { | ||
test: signal | ||
} | ||
}); | ||
const controller = Controller(rootModule); | ||
autorun(() => { | ||
controller.state.test; | ||
hasUpdated++; | ||
}); | ||
assert.equal(controller.state.test, 'BAR'); | ||
controller.signals.test(); | ||
assert.equal(hasUpdated, 2); | ||
}); | ||
it('should work with fluent api', () => { | ||
@@ -130,0 +156,0 @@ const Sequence = SequenceFactory(); |
@@ -317,3 +317,7 @@ import { extractModuleProp, isObject, BaseModel } from 'cerebral/internal'; | ||
const extended = extendObservable(root, Object.keys(extension).reduce((root, key) => { | ||
if (extension[key] instanceof ComputedClass) { | ||
const propertyDescriptor = Object.getOwnPropertyDescriptor(extension, key); | ||
if (propertyDescriptor && 'get' in propertyDescriptor) { | ||
Object.defineProperty(root, key, propertyDescriptor); | ||
} | ||
else if (extension[key] instanceof ComputedClass) { | ||
extension[key].getState = () => ({ state: extended, root: this.state }); | ||
@@ -320,0 +324,0 @@ root[key] = extension[key]; |
{ | ||
"name": "@cerebral/fluent", | ||
"version": "1.0.0-1518821845306", | ||
"version": "1.0.0-1518858486644", | ||
"description": "Makes Cerebral typescript friendly", | ||
@@ -27,3 +27,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"cerebral": "^4.2.0-1518821845307", | ||
"cerebral": "^4.2.0-1518858486644", | ||
"mobx": "^3.4.1" | ||
@@ -30,0 +30,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61595
1505