@cycle/core
Advanced tools
Comparing version 5.0.1 to 6.0.0-rc1
@@ -7,24 +7,24 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Cycle = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
function makeRequestProxies(drivers) { | ||
var requestProxies = {}; | ||
function makeSinkProxies(drivers) { | ||
var sinkProxies = {}; | ||
for (var _name in drivers) { | ||
if (drivers.hasOwnProperty(_name)) { | ||
requestProxies[_name] = new Rx.ReplaySubject(1); | ||
sinkProxies[_name] = new Rx.ReplaySubject(1); | ||
} | ||
} | ||
return requestProxies; | ||
return sinkProxies; | ||
} | ||
function callDrivers(drivers, requestProxies) { | ||
var responses = {}; | ||
function callDrivers(drivers, sinkProxies) { | ||
var sources = {}; | ||
for (var _name2 in drivers) { | ||
if (drivers.hasOwnProperty(_name2)) { | ||
responses[_name2] = drivers[_name2](requestProxies[_name2], _name2); | ||
sources[_name2] = drivers[_name2](sinkProxies[_name2], _name2); | ||
} | ||
} | ||
return responses; | ||
return sources; | ||
} | ||
function attachDisposeToRequests(requests, replicationSubscription) { | ||
Object.defineProperty(requests, "dispose", { | ||
function attachDisposeToSinks(sinks, replicationSubscription) { | ||
Object.defineProperty(sinks, "dispose", { | ||
enumerable: false, | ||
@@ -35,10 +35,10 @@ value: function value() { | ||
}); | ||
return requests; | ||
return sinks; | ||
} | ||
function makeDisposeResponses(responses) { | ||
function makeDisposeSources(sources) { | ||
return function dispose() { | ||
for (var _name3 in responses) { | ||
if (responses.hasOwnProperty(_name3) && typeof responses[_name3].dispose === "function") { | ||
responses[_name3].dispose(); | ||
for (var _name3 in sources) { | ||
if (sources.hasOwnProperty(_name3) && typeof sources[_name3].dispose === "function") { | ||
sources[_name3].dispose(); | ||
} | ||
@@ -49,8 +49,8 @@ } | ||
function attachDisposeToResponses(responses) { | ||
Object.defineProperty(responses, "dispose", { | ||
function attachDisposeToSources(sources) { | ||
Object.defineProperty(sources, "dispose", { | ||
enumerable: false, | ||
value: makeDisposeResponses(responses) | ||
value: makeDisposeSources(sources) | ||
}); | ||
return responses; | ||
return sources; | ||
} | ||
@@ -108,9 +108,9 @@ | ||
var requestProxies = makeRequestProxies(drivers); | ||
var responses = callDrivers(drivers, requestProxies); | ||
var requests = main(responses); | ||
var subscription = replicateMany(requests, requestProxies).subscribe(); | ||
var requestsWithDispose = attachDisposeToRequests(requests, subscription); | ||
var responsesWithDispose = attachDisposeToResponses(responses); | ||
return [requestsWithDispose, responsesWithDispose]; | ||
var sinkProxies = makeSinkProxies(drivers); | ||
var sources = callDrivers(drivers, sinkProxies); | ||
var sinks = main(sources); | ||
var subscription = replicateMany(sinks, sinkProxies).subscribe(); | ||
var sinksWithDispose = attachDisposeToSinks(sinks, subscription); | ||
var sourcesWithDispose = attachDisposeToSources(sources); | ||
return { sources: sourcesWithDispose, sinks: sinksWithDispose }; | ||
} | ||
@@ -123,4 +123,4 @@ | ||
* | ||
* The `main` function expects a collection of "driver response" Observables | ||
* as input, and should return a collection of "driver request" Observables. | ||
* The `main` function expects a collection of "driver source" Observables | ||
* as input, and should return a collection of "driver sink" Observables. | ||
* A "collection of Observables" is a JavaScript object where | ||
@@ -130,9 +130,9 @@ * keys match the driver names registered by the `drivers` object, and values | ||
* | ||
* @param {Function} main a function that takes `responses` as input | ||
* and outputs a collection of `requests` Observables. | ||
* @param {Function} main a function that takes `sources` as input | ||
* and outputs a collection of `sinks` Observables. | ||
* @param {Object} drivers an object where keys are driver names and values | ||
* are driver functions. | ||
* @return {Array} an array where the first object is the collection of driver | ||
* requests, and the second object is the collection of driver responses, that | ||
* can be used for debugging or testing. | ||
* @return {Object} an object with two properties: `sources` and `sinks`. | ||
* `sinks` is the collection of driver sinks, and `sources` is the collection | ||
* of driver sources, that can be used for debugging or testing. | ||
* @function run | ||
@@ -139,0 +139,0 @@ */ |
@@ -1,1 +0,1 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Cycle=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(global){"use strict";var Rx=typeof window!=="undefined"?window["Rx"]:typeof global!=="undefined"?global["Rx"]:null;function makeRequestProxies(drivers){var requestProxies={};for(var _name in drivers){if(drivers.hasOwnProperty(_name)){requestProxies[_name]=new Rx.ReplaySubject(1)}}return requestProxies}function callDrivers(drivers,requestProxies){var responses={};for(var _name2 in drivers){if(drivers.hasOwnProperty(_name2)){responses[_name2]=drivers[_name2](requestProxies[_name2],_name2)}}return responses}function attachDisposeToRequests(requests,replicationSubscription){Object.defineProperty(requests,"dispose",{enumerable:false,value:function value(){replicationSubscription.dispose()}});return requests}function makeDisposeResponses(responses){return function dispose(){for(var _name3 in responses){if(responses.hasOwnProperty(_name3)&&typeof responses[_name3].dispose==="function"){responses[_name3].dispose()}}}}function attachDisposeToResponses(responses){Object.defineProperty(responses,"dispose",{enumerable:false,value:makeDisposeResponses(responses)});return responses}function logToConsoleError(err){var target=err.stack||err;if(console&&console.error){console.error(target)}}function replicateMany(observables,subjects){return Rx.Observable.create(function(observer){var subscription=new Rx.CompositeDisposable;setTimeout(function(){for(var _name4 in observables){if(observables.hasOwnProperty(_name4)&&subjects.hasOwnProperty(_name4)&&!subjects[_name4].isDisposed){subscription.add(observables[_name4].doOnError(logToConsoleError).subscribe(subjects[_name4].asObserver()))}}observer.onNext(subscription)},1);return function dispose(){subscription.dispose();for(var x in subjects){if(subjects.hasOwnProperty(x)){subjects[x].dispose()}}}})}function isObjectEmpty(obj){for(var key in obj){if(obj.hasOwnProperty(key)){return false}}return true}function run(main,drivers){if(typeof main!=="function"){throw new Error("First argument given to Cycle.run() must be the 'main' "+"function.")}if(typeof drivers!=="object"||drivers===null){throw new Error("Second argument given to Cycle.run() must be an object "+"with driver functions as properties.")}if(isObjectEmpty(drivers)){throw new Error("Second argument given to Cycle.run() must be an object "+"with at least one driver function declared as a property.")}var requestProxies=makeRequestProxies(drivers);var responses=callDrivers(drivers,requestProxies);var requests=main(responses);var subscription=replicateMany(requests,requestProxies).subscribe();var requestsWithDispose=attachDisposeToRequests(requests,subscription);var responsesWithDispose=attachDisposeToResponses(responses);return[requestsWithDispose,responsesWithDispose]}var Cycle={run:run};module.exports=Cycle}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1])(1)}); | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Cycle=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(global){"use strict";var Rx=typeof window!=="undefined"?window["Rx"]:typeof global!=="undefined"?global["Rx"]:null;function makeSinkProxies(drivers){var sinkProxies={};for(var _name in drivers){if(drivers.hasOwnProperty(_name)){sinkProxies[_name]=new Rx.ReplaySubject(1)}}return sinkProxies}function callDrivers(drivers,sinkProxies){var sources={};for(var _name2 in drivers){if(drivers.hasOwnProperty(_name2)){sources[_name2]=drivers[_name2](sinkProxies[_name2],_name2)}}return sources}function attachDisposeToSinks(sinks,replicationSubscription){Object.defineProperty(sinks,"dispose",{enumerable:false,value:function value(){replicationSubscription.dispose()}});return sinks}function makeDisposeSources(sources){return function dispose(){for(var _name3 in sources){if(sources.hasOwnProperty(_name3)&&typeof sources[_name3].dispose==="function"){sources[_name3].dispose()}}}}function attachDisposeToSources(sources){Object.defineProperty(sources,"dispose",{enumerable:false,value:makeDisposeSources(sources)});return sources}function logToConsoleError(err){var target=err.stack||err;if(console&&console.error){console.error(target)}}function replicateMany(observables,subjects){return Rx.Observable.create(function(observer){var subscription=new Rx.CompositeDisposable;setTimeout(function(){for(var _name4 in observables){if(observables.hasOwnProperty(_name4)&&subjects.hasOwnProperty(_name4)&&!subjects[_name4].isDisposed){subscription.add(observables[_name4].doOnError(logToConsoleError).subscribe(subjects[_name4].asObserver()))}}observer.onNext(subscription)},1);return function dispose(){subscription.dispose();for(var x in subjects){if(subjects.hasOwnProperty(x)){subjects[x].dispose()}}}})}function isObjectEmpty(obj){for(var key in obj){if(obj.hasOwnProperty(key)){return false}}return true}function run(main,drivers){if(typeof main!=="function"){throw new Error("First argument given to Cycle.run() must be the 'main' "+"function.")}if(typeof drivers!=="object"||drivers===null){throw new Error("Second argument given to Cycle.run() must be an object "+"with driver functions as properties.")}if(isObjectEmpty(drivers)){throw new Error("Second argument given to Cycle.run() must be an object "+"with at least one driver function declared as a property.")}var sinkProxies=makeSinkProxies(drivers);var sources=callDrivers(drivers,sinkProxies);var sinks=main(sources);var subscription=replicateMany(sinks,sinkProxies).subscribe();var sinksWithDispose=attachDisposeToSinks(sinks,subscription);var sourcesWithDispose=attachDisposeToSources(sources);return{sources:sourcesWithDispose,sinks:sinksWithDispose}}var Cycle={run:run};module.exports=Cycle}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}]},{},[1])(1)}); |
@@ -11,4 +11,4 @@ | ||
The `main` function expects a collection of "driver response" Observables | ||
as input, and should return a collection of "driver request" Observables. | ||
The `main` function expects a collection of "driver source" Observables | ||
as input, and should return a collection of "driver sink" Observables. | ||
A "collection of Observables" is a JavaScript object where | ||
@@ -20,3 +20,3 @@ keys match the driver names registered by the `drivers` object, and values | ||
- `main :: Function` a function that takes `responses` as input and outputs a collection of `requests` Observables. | ||
- `main :: Function` a function that takes `sources` as input and outputs a collection of `sinks` Observables. | ||
- `drivers :: Object` an object where keys are driver names and values are driver functions. | ||
@@ -26,3 +26,6 @@ | ||
*(Array)* an array where the first object is the collection of driver requests, and the second object is the collection of driver responses, that | ||
can be used for debugging or testing. | ||
*(Object)* an object with two properties: `sources` and `sinks`. `sinks` is the collection of driver sinks, and `sources` is the collection | ||
of driver sources, that can be used for debugging or testing. | ||
- - - | ||
@@ -5,24 +5,24 @@ "use strict"; | ||
function makeRequestProxies(drivers) { | ||
var requestProxies = {}; | ||
function makeSinkProxies(drivers) { | ||
var sinkProxies = {}; | ||
for (var _name in drivers) { | ||
if (drivers.hasOwnProperty(_name)) { | ||
requestProxies[_name] = new Rx.ReplaySubject(1); | ||
sinkProxies[_name] = new Rx.ReplaySubject(1); | ||
} | ||
} | ||
return requestProxies; | ||
return sinkProxies; | ||
} | ||
function callDrivers(drivers, requestProxies) { | ||
var responses = {}; | ||
function callDrivers(drivers, sinkProxies) { | ||
var sources = {}; | ||
for (var _name2 in drivers) { | ||
if (drivers.hasOwnProperty(_name2)) { | ||
responses[_name2] = drivers[_name2](requestProxies[_name2], _name2); | ||
sources[_name2] = drivers[_name2](sinkProxies[_name2], _name2); | ||
} | ||
} | ||
return responses; | ||
return sources; | ||
} | ||
function attachDisposeToRequests(requests, replicationSubscription) { | ||
Object.defineProperty(requests, "dispose", { | ||
function attachDisposeToSinks(sinks, replicationSubscription) { | ||
Object.defineProperty(sinks, "dispose", { | ||
enumerable: false, | ||
@@ -33,10 +33,10 @@ value: function value() { | ||
}); | ||
return requests; | ||
return sinks; | ||
} | ||
function makeDisposeResponses(responses) { | ||
function makeDisposeSources(sources) { | ||
return function dispose() { | ||
for (var _name3 in responses) { | ||
if (responses.hasOwnProperty(_name3) && typeof responses[_name3].dispose === "function") { | ||
responses[_name3].dispose(); | ||
for (var _name3 in sources) { | ||
if (sources.hasOwnProperty(_name3) && typeof sources[_name3].dispose === "function") { | ||
sources[_name3].dispose(); | ||
} | ||
@@ -47,8 +47,8 @@ } | ||
function attachDisposeToResponses(responses) { | ||
Object.defineProperty(responses, "dispose", { | ||
function attachDisposeToSources(sources) { | ||
Object.defineProperty(sources, "dispose", { | ||
enumerable: false, | ||
value: makeDisposeResponses(responses) | ||
value: makeDisposeSources(sources) | ||
}); | ||
return responses; | ||
return sources; | ||
} | ||
@@ -106,9 +106,9 @@ | ||
var requestProxies = makeRequestProxies(drivers); | ||
var responses = callDrivers(drivers, requestProxies); | ||
var requests = main(responses); | ||
var subscription = replicateMany(requests, requestProxies).subscribe(); | ||
var requestsWithDispose = attachDisposeToRequests(requests, subscription); | ||
var responsesWithDispose = attachDisposeToResponses(responses); | ||
return [requestsWithDispose, responsesWithDispose]; | ||
var sinkProxies = makeSinkProxies(drivers); | ||
var sources = callDrivers(drivers, sinkProxies); | ||
var sinks = main(sources); | ||
var subscription = replicateMany(sinks, sinkProxies).subscribe(); | ||
var sinksWithDispose = attachDisposeToSinks(sinks, subscription); | ||
var sourcesWithDispose = attachDisposeToSources(sources); | ||
return { sources: sourcesWithDispose, sinks: sinksWithDispose }; | ||
} | ||
@@ -121,4 +121,4 @@ | ||
* | ||
* The `main` function expects a collection of "driver response" Observables | ||
* as input, and should return a collection of "driver request" Observables. | ||
* The `main` function expects a collection of "driver source" Observables | ||
* as input, and should return a collection of "driver sink" Observables. | ||
* A "collection of Observables" is a JavaScript object where | ||
@@ -128,9 +128,9 @@ * keys match the driver names registered by the `drivers` object, and values | ||
* | ||
* @param {Function} main a function that takes `responses` as input | ||
* and outputs a collection of `requests` Observables. | ||
* @param {Function} main a function that takes `sources` as input | ||
* and outputs a collection of `sinks` Observables. | ||
* @param {Object} drivers an object where keys are driver names and values | ||
* are driver functions. | ||
* @return {Array} an array where the first object is the collection of driver | ||
* requests, and the second object is the collection of driver responses, that | ||
* can be used for debugging or testing. | ||
* @return {Object} an object with two properties: `sources` and `sinks`. | ||
* `sinks` is the collection of driver sinks, and `sources` is the collection | ||
* of driver sources, that can be used for debugging or testing. | ||
* @function run | ||
@@ -137,0 +137,0 @@ */ |
{ | ||
"name": "@cycle/core", | ||
"version": "5.0.1", | ||
"version": "6.0.0-rc1", | ||
"author": "Andre Staltz", | ||
@@ -5,0 +5,0 @@ "description": "A fully reactive JavaScript framework for Human-Computer Interaction", |
let Rx = require(`rx`) | ||
function makeRequestProxies(drivers) { | ||
let requestProxies = {} | ||
function makeSinkProxies(drivers) { | ||
let sinkProxies = {} | ||
for (let name in drivers) { | ||
if (drivers.hasOwnProperty(name)) { | ||
requestProxies[name] = new Rx.ReplaySubject(1) | ||
sinkProxies[name] = new Rx.ReplaySubject(1) | ||
} | ||
} | ||
return requestProxies | ||
return sinkProxies | ||
} | ||
function callDrivers(drivers, requestProxies) { | ||
let responses = {} | ||
function callDrivers(drivers, sinkProxies) { | ||
let sources = {} | ||
for (let name in drivers) { | ||
if (drivers.hasOwnProperty(name)) { | ||
responses[name] = drivers[name](requestProxies[name], name) | ||
sources[name] = drivers[name](sinkProxies[name], name) | ||
} | ||
} | ||
return responses | ||
return sources | ||
} | ||
function attachDisposeToRequests(requests, replicationSubscription) { | ||
Object.defineProperty(requests, `dispose`, { | ||
function attachDisposeToSinks(sinks, replicationSubscription) { | ||
Object.defineProperty(sinks, `dispose`, { | ||
enumerable: false, | ||
value: () => { replicationSubscription.dispose() }, | ||
}) | ||
return requests | ||
return sinks | ||
} | ||
function makeDisposeResponses(responses) { | ||
function makeDisposeSources(sources) { | ||
return function dispose() { | ||
for (let name in responses) { | ||
if (responses.hasOwnProperty(name) && | ||
typeof responses[name].dispose === `function`) | ||
for (let name in sources) { | ||
if (sources.hasOwnProperty(name) && | ||
typeof sources[name].dispose === `function`) | ||
{ | ||
responses[name].dispose() | ||
sources[name].dispose() | ||
} | ||
@@ -43,8 +43,8 @@ } | ||
function attachDisposeToResponses(responses) { | ||
Object.defineProperty(responses, `dispose`, { | ||
function attachDisposeToSources(sources) { | ||
Object.defineProperty(sources, `dispose`, { | ||
enumerable: false, | ||
value: makeDisposeResponses(responses), | ||
value: makeDisposeSources(sources), | ||
}) | ||
return responses | ||
return sources | ||
} | ||
@@ -112,9 +112,9 @@ | ||
let requestProxies = makeRequestProxies(drivers) | ||
let responses = callDrivers(drivers, requestProxies) | ||
let requests = main(responses) | ||
let subscription = replicateMany(requests, requestProxies).subscribe() | ||
let requestsWithDispose = attachDisposeToRequests(requests, subscription) | ||
let responsesWithDispose = attachDisposeToResponses(responses) | ||
return [requestsWithDispose, responsesWithDispose] | ||
let sinkProxies = makeSinkProxies(drivers) | ||
let sources = callDrivers(drivers, sinkProxies) | ||
let sinks = main(sources) | ||
let subscription = replicateMany(sinks, sinkProxies).subscribe() | ||
let sinksWithDispose = attachDisposeToSinks(sinks, subscription) | ||
let sourcesWithDispose = attachDisposeToSources(sources) | ||
return {sources: sourcesWithDispose, sinks: sinksWithDispose} | ||
} | ||
@@ -127,4 +127,4 @@ | ||
* | ||
* The `main` function expects a collection of "driver response" Observables | ||
* as input, and should return a collection of "driver request" Observables. | ||
* The `main` function expects a collection of "driver source" Observables | ||
* as input, and should return a collection of "driver sink" Observables. | ||
* A "collection of Observables" is a JavaScript object where | ||
@@ -134,9 +134,9 @@ * keys match the driver names registered by the `drivers` object, and values | ||
* | ||
* @param {Function} main a function that takes `responses` as input | ||
* and outputs a collection of `requests` Observables. | ||
* @param {Function} main a function that takes `sources` as input | ||
* and outputs a collection of `sinks` Observables. | ||
* @param {Object} drivers an object where keys are driver names and values | ||
* are driver functions. | ||
* @return {Array} an array where the first object is the collection of driver | ||
* requests, and the second object is the collection of driver responses, that | ||
* can be used for debugging or testing. | ||
* @return {Object} an object with two properties: `sources` and `sinks`. | ||
* `sinks` is the collection of driver sinks, and `sources` is the collection | ||
* of driver sources, that can be used for debugging or testing. | ||
* @function run | ||
@@ -143,0 +143,0 @@ */ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable */ | ||
'use strict'; | ||
@@ -34,3 +35,3 @@ /* global describe, it */ | ||
it('should return requests object and responses object', function () { | ||
it('should return sinks object and sources object', function () { | ||
function app(ext) { | ||
@@ -44,25 +45,25 @@ return { | ||
} | ||
let [left, right] = Cycle.run(app, {other: driver}); | ||
assert.strictEqual(typeof left, 'object'); | ||
assert.strictEqual(typeof left.other.subscribe, 'function'); | ||
assert.strictEqual(typeof right, 'object'); | ||
assert.notStrictEqual(typeof right.other, 'undefined'); | ||
assert.notStrictEqual(right.other, null); | ||
assert.strictEqual(typeof right.other.subscribe, 'function'); | ||
let {sinks, sources} = Cycle.run(app, {other: driver}); | ||
assert.strictEqual(typeof sinks, 'object'); | ||
assert.strictEqual(typeof sinks.other.subscribe, 'function'); | ||
assert.strictEqual(typeof sources, 'object'); | ||
assert.notStrictEqual(typeof sources.other, 'undefined'); | ||
assert.notStrictEqual(sources.other, null); | ||
assert.strictEqual(typeof sources.other.subscribe, 'function'); | ||
}); | ||
it('should return a disposable drivers output', function (done) { | ||
function app(res) { | ||
function app(sources) { | ||
return { | ||
other: res.other.take(6).map(x => String(x)).startWith('a') | ||
other: sources.other.take(6).map(x => String(x)).startWith('a') | ||
}; | ||
} | ||
function driver(req) { | ||
return req.map(x => x.charCodeAt(0)).delay(1); | ||
function driver(sink) { | ||
return sink.map(x => x.charCodeAt(0)).delay(1); | ||
} | ||
let [requests, responses] = Cycle.run(app, {other: driver}); | ||
responses.other.subscribe(x => { | ||
let {sinks, sources} = Cycle.run(app, {other: driver}); | ||
sources.other.subscribe(x => { | ||
assert.strictEqual(x, 97); | ||
requests.dispose(); | ||
responses.dispose(); | ||
sinks.dispose(); | ||
sources.dispose(); | ||
done(); | ||
@@ -79,11 +80,11 @@ }); | ||
let mutable = 'wrong'; | ||
function driver(req) { | ||
return req.map(x => 'a' + 10) | ||
function driver(sink) { | ||
return sink.map(x => 'a' + 10) | ||
} | ||
let [requests, responses] = Cycle.run(app, {other: driver}); | ||
responses.other.take(1).subscribe(x => { | ||
let {sinks, sources} = Cycle.run(app, {other: driver}); | ||
sources.other.take(1).subscribe(x => { | ||
assert.strictEqual(x, 'a10'); | ||
assert.strictEqual(mutable, 'correct'); | ||
requests.dispose(); | ||
responses.dispose(); | ||
sinks.dispose(); | ||
sources.dispose(); | ||
done(); | ||
@@ -100,10 +101,10 @@ }); | ||
} | ||
let [requests, responses] = Cycle.run(app, { | ||
let {sinks, sources} = Cycle.run(app, { | ||
other: number$ => number$.map(number => 'x' + number) | ||
}); | ||
responses.other.subscribe(function (x) { | ||
sources.other.subscribe(function (x) { | ||
assert.notStrictEqual(x, 'x3'); | ||
if (x === 'x2') { | ||
requests.dispose(); | ||
responses.dispose(); | ||
sinks.dispose(); | ||
sources.dispose(); | ||
setTimeout(() => { | ||
@@ -120,5 +121,5 @@ done(); | ||
function main(responses) { | ||
function main(sources) { | ||
return { | ||
other: responses.other.take(1).startWith('a').map(() => { | ||
other: sources.other.take(1).startWith('a').map(() => { | ||
throw new Error('malfunction'); | ||
@@ -125,0 +126,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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
530
33185
3