UNPKG

@danielkalen/simplybind

Version:

Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.

34 lines (25 loc) 893 B
suite ".conditionAll()", ()-> suiteSetup(restartSandbox) test "Behaves the same way as .condition() does, except it applies the condition to all of the declared subscribers", ()-> shouldAllowUpdate = false dispatcher = 'prop':0 objectA.prop1 = objectB.prop1 = objectC.prop1 = 0 SimplyBind('prop').of(dispatcher) .to('prop1').of(objectA) .and.to('prop1').of(objectB) .and.to('prop1').of(objectC) .conditionAll ()-> shouldAllowUpdate dispatcher.prop = 1 expect(objectA.prop1).to.equal 0 expect(objectB.prop1).to.equal 0 expect(objectC.prop1).to.equal 0 dispatcher.prop = 2 expect(objectA.prop1).to.equal 0 expect(objectB.prop1).to.equal 0 expect(objectC.prop1).to.equal 0 shouldAllowUpdate = true dispatcher.prop = 3 expect(objectA.prop1).to.equal 3 expect(objectB.prop1).to.equal 3 expect(objectC.prop1).to.equal 3 restartSandbox()