Comparing version
@@ -41,3 +41,5 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); | ||
_options$preventIniti = options.preventInitialize, | ||
preventInitialize = _options$preventIniti === undefined ? false : _options$preventIniti; | ||
preventInitialize = _options$preventIniti === undefined ? false : _options$preventIniti, | ||
_options$returnSequen = options.returnSequencePromise, | ||
returnSequencePromise = _options$returnSequen === undefined ? false : _options$returnSequen; | ||
@@ -57,2 +59,3 @@ | ||
_this.throwToConsole = throwToConsole; | ||
_this.returnSequencePromise = returnSequencePromise; | ||
@@ -174,3 +177,3 @@ _this.devtools = devtools; | ||
this.run(name, sequence, payload, function (error) { | ||
var callback = function callback(error) { | ||
if (error) { | ||
@@ -239,3 +242,9 @@ var sequencePath = ensurePath(error.execution.name); | ||
} | ||
}); | ||
}; | ||
if (this.returnSequencePromise) { | ||
return this.run(name, sequence, payload).catch(callback); | ||
} else { | ||
this.run(name, sequence, payload, callback); | ||
} | ||
} | ||
@@ -242,0 +251,0 @@ /* |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -69,2 +71,11 @@ | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe(watcher, cb) { | ||
if (!this.watcherSubscription) { | ||
this.watcherSubscription = _get(Computed.prototype.__proto__ || Object.getPrototypeOf(Computed.prototype), 'subscribe', this).call(this, this, this.onSubscription); | ||
} | ||
return _get(Computed.prototype.__proto__ || Object.getPrototypeOf(Computed.prototype), 'subscribe', this).call(this, watcher, cb); | ||
} | ||
}, { | ||
key: 'onSubscription', | ||
@@ -71,0 +82,0 @@ value: function onSubscription() { |
@@ -63,3 +63,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
_this.version = "5.0.0-1527015081471"; | ||
_this.version = "5.0.0-1527107988207"; | ||
_this.debuggerWatchMap = {}; | ||
@@ -66,0 +66,0 @@ _this.debuggerComputedMap = {}; |
export default function (target, value) { | ||
function concat(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.concat: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.concat: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].concat(context.resolve.path(target), context.resolve.value(value)); | ||
context.store.concat(target, value); | ||
} | ||
concat.displayName = 'operator.concat(' + String(target) + ', ' + String(value) + ')'; | ||
concat.displayName = 'factory.concat(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -12,0 +12,0 @@ return concat; |
@@ -7,3 +7,3 @@ function equalsFactory(target) { | ||
if (!resolve.isTag(target, 'state', 'props', 'moduleState')) { | ||
throw new Error('Cerebral operator.equals: You have to use the STATE, PROPS or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.equals: You have to use the STATE, PROPS or MODULESTATE tag as first argument'); | ||
} | ||
@@ -16,3 +16,3 @@ | ||
equals.displayName = 'operator.equals(' + String(target) + ')'; | ||
equals.displayName = 'factory.equals(' + String(target) + ')'; | ||
@@ -19,0 +19,0 @@ return equals; |
@@ -5,3 +5,3 @@ export default function (target) { | ||
function increment(_ref) { | ||
var state = _ref.state, | ||
var store = _ref.store, | ||
module = _ref.module, | ||
@@ -12,3 +12,3 @@ props = _ref.props, | ||
if (!resolve.isTag(target, 'state', 'props', 'moduleState')) { | ||
throw new Error('Cerebral operator.increment: You have to use the STATE, MODULE or PROPS tag as first argument'); | ||
throw new Error('Cerebral factory.increment: You have to use the STATE, MODULESTATE or PROPS tag as first argument'); | ||
} | ||
@@ -19,10 +19,8 @@ | ||
if (!Number.isInteger(resolvedValue)) { | ||
throw new Error('Cerebral operator.increment: You must increment by integer values'); | ||
throw new Error('Cerebral factory.increment: You must increment by integer values'); | ||
} | ||
var invalidStateMsg = 'Cerebral operator.increment: You must increment integer values'; | ||
if (target.type === 'state') { | ||
state.increment(resolve.path(target), resolvedValue); | ||
} else if (target.type === 'moduleState') { | ||
module.increment(resolve.path(target), resolvedValue); | ||
var invalidStateMsg = 'Cerebral factory.increment: You must increment integer values'; | ||
if (target.type === 'state' || target.type === 'moduleState') { | ||
store.increment(target, resolvedValue); | ||
} else { | ||
@@ -46,3 +44,3 @@ var result = Object.assign({}, props); | ||
increment.displayName = 'operator.increment(' + String(target) + ', ' + String(value) + ')'; | ||
increment.displayName = 'factory.increment(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -49,0 +47,0 @@ return increment; |
@@ -0,1 +1,3 @@ | ||
export { sequence, parallel } from 'function-tree'; | ||
export { default as debounce } from './debounce'; | ||
@@ -2,0 +4,0 @@ export { default as when } from './when'; |
@@ -9,9 +9,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function merge(context) { | ||
var _context$target$type; | ||
var _context$store; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.merge: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.merge: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
(_context$target$type = context[target.type]).merge.apply(_context$target$type, [context.resolve.path(target)].concat(_toConsumableArray(values.map(function (value) { | ||
(_context$store = context.store).merge.apply(_context$store, [target].concat(_toConsumableArray(values.map(function (value) { | ||
if (context.resolve.isTag(value)) { | ||
@@ -29,3 +29,3 @@ return context.resolve.value(value); | ||
merge.displayName = 'operator.merge(' + String(target) + ', ' + values.map(function (value) { | ||
merge.displayName = 'factory.merge(' + String(target) + ', ' + values.map(function (value) { | ||
return String(value); | ||
@@ -32,0 +32,0 @@ }).join(',') + ')'; |
export default function (target) { | ||
function pop(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.pop: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.pop: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].pop(context.resolve.path(target)); | ||
context.store.pop(target); | ||
} | ||
pop.displayName = 'operator.pop(' + String(target) + ')'; | ||
pop.displayName = 'factory.pop(' + String(target) + ')'; | ||
@@ -12,0 +12,0 @@ return pop; |
export default function (target, value) { | ||
function push(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.push: You have to use the STATE TAG as first argument'); | ||
throw new Error('Cerebral factory.push: You have to use the STATE TAG as first argument'); | ||
} | ||
context[target.type].push(context.resolve.path(target), context.resolve.value(value)); | ||
context.store.push(target, value); | ||
} | ||
push.displayName = 'operator.push(' + String(target) + ')'; | ||
push.displayName = 'factory.push(' + String(target) + ')'; | ||
@@ -12,0 +12,0 @@ return push; |
@@ -5,4 +5,3 @@ import { isObject } from '../utils'; | ||
function set(_ref) { | ||
var state = _ref.state, | ||
module = _ref.module, | ||
var store = _ref.store, | ||
props = _ref.props, | ||
@@ -12,3 +11,3 @@ resolve = _ref.resolve; | ||
if (!resolve.isTag(target, 'state', 'props', 'moduleState')) { | ||
throw new Error('Cerebral operator.set: You have to use the STATE, PROPS or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.set: You have to use the STATE, PROPS or MODULESTATE tag as first argument'); | ||
} | ||
@@ -25,5 +24,3 @@ | ||
if (target.type === 'state') { | ||
state.set(resolve.path(target), resolvedValue); | ||
} else if (target.type === 'moduleState') { | ||
module.set(resolve.path(target), resolvedValue); | ||
store.set(target, resolvedValue); | ||
} else { | ||
@@ -42,3 +39,3 @@ var result = Object.assign({}, props); | ||
set.displayName = 'operator.set(' + String(target) + ', ' + String(value) + ')'; | ||
set.displayName = 'factory.set(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -45,0 +42,0 @@ return set; |
export default function (target) { | ||
function shift(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.shift: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.shift: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].shift(context.resolve.path(target)); | ||
context.store.shift(target); | ||
} | ||
shift.displayName = 'operator.shift(' + String(target) + ')'; | ||
shift.displayName = 'factory.shift(' + String(target) + ')'; | ||
@@ -12,0 +12,0 @@ return shift; |
@@ -1,3 +0,1 @@ | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
export default function (target) { | ||
@@ -9,16 +7,12 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
function splice(context) { | ||
var _context$target$type; | ||
var _context$store; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.splice: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.splice: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
var spliceArgs = args.map(function (arg) { | ||
return context.resolve.value(arg); | ||
}); | ||
(_context$target$type = context[target.type]).splice.apply(_context$target$type, [context.resolve.path(target)].concat(_toConsumableArray(spliceArgs))); | ||
(_context$store = context.store).splice.apply(_context$store, [target].concat(args)); | ||
} | ||
splice.displayName = 'operator.splice(' + String(target) + ', ' + args.map(function (arg) { | ||
splice.displayName = 'factory.splice(' + String(target) + ', ' + args.map(function (arg) { | ||
return String(arg); | ||
@@ -25,0 +19,0 @@ }).join(',') + ')'; |
export default function (target) { | ||
function toggle(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.toggle: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.toggle: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
var path = context.resolve.path(target); | ||
context[target.type].toggle(path); | ||
context.store.toggle(target); | ||
} | ||
toggle.displayName = 'operator.toggle(' + String(target) + ')'; | ||
toggle.displayName = 'factory.toggle(' + String(target) + ')'; | ||
@@ -14,0 +12,0 @@ return toggle; |
export default function (target) { | ||
function unset(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.unset: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.unset: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].unset(context.resolve.path(target)); | ||
context.store.unset(target); | ||
} | ||
unset.displayName = 'operator.unset(' + String(target) + ')'; | ||
unset.displayName = 'factory.unset(' + String(target) + ')'; | ||
@@ -12,0 +12,0 @@ return unset; |
export default function (target, value) { | ||
function unshift(context) { | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.unshift: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.unshift: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].unshift(context.resolve.path(target), context.resolve.value(value)); | ||
context.store.unshift(target, value); | ||
} | ||
unshift.displayName = 'operator.unshift(' + String(target) + ', ' + String(value) + ')'; | ||
unshift.displayName = 'factory.unshift(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -12,0 +12,0 @@ return unshift; |
@@ -19,6 +19,6 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
if (valueTemplates.length > 0 && !(valueTemplates[0] instanceof Tag)) { | ||
throw new Error('Cerebral operator.when: You have to use the STATE, MODULE or PROPS tag as values, see: ' + HELP_URL); | ||
throw new Error('Cerebral factory.when: You have to use the STATE, MODULESTATE or PROPS tag as values, see: ' + HELP_URL); | ||
} | ||
if (!path || !path.true || !path.false) { | ||
throw new Error('Cerebral operator.when: true/false paths need to be provided, see: http://cerebraljs.com/docs/api/factories.html#when'); | ||
throw new Error('Cerebral factory.when: true/false paths need to be provided, see: http://cerebraljs.com/docs/api/factories.html#when'); | ||
} | ||
@@ -33,3 +33,3 @@ var values = valueTemplates.map(function (value) { | ||
when.displayName = 'operator.when(' + args.filter(function (arg) { | ||
when.displayName = 'factory.when(' + args.filter(function (arg) { | ||
return typeof arg !== 'function'; | ||
@@ -36,0 +36,0 @@ }).map(function (arg) { |
@@ -37,3 +37,2 @@ import ControllerClass from './Controller'; | ||
export { default as Reaction } from './Reaction'; | ||
export { sequence, parallel } from 'function-tree'; | ||
@@ -40,0 +39,0 @@ export { default as View } from './View'; |
@@ -22,3 +22,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var moduleStub = { | ||
controller: controller, | ||
app: controller, | ||
path: stringPath, | ||
@@ -43,3 +43,3 @@ name: path.slice().pop() | ||
run: function run(payload) { | ||
controller.runSequence(path.concat(sequenceKey).join('.'), sequence, payload); | ||
return controller.runSequence(path.concat(sequenceKey).join('.'), sequence, payload); | ||
} | ||
@@ -46,0 +46,0 @@ }; |
@@ -9,3 +9,3 @@ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
import { Controller } from '../'; | ||
import App from '../'; | ||
import { Provider as FTProvider } from 'function-tree'; | ||
@@ -148,3 +148,3 @@ import { DevtoolsBase } from 'function-tree/devtools'; | ||
this.controller = Controller(rootModule, { | ||
this.controller = App(rootModule, { | ||
devtools: new SnapshotDevtool({ | ||
@@ -151,0 +151,0 @@ host: 'local' |
@@ -1,38 +0,38 @@ | ||
import { Tag } from '../tags' | ||
export { debounce } from 'function-tree/factories' | ||
export { sequence, parallel } from 'function-tree' | ||
export function concat(target: Tag, value: Tag | any[]): Function | ||
export function increment(target: Tag, amount?: Tag | number): Function | ||
export function merge(target: Tag, value: Tag | any): Function | ||
export function pop(target: Tag): Function | ||
export function push(target: Tag, value: Tag | any): Function | ||
export function set(target: Tag, value: Tag | any): Function | ||
export function shift(target: Tag): Function | ||
export function concat<T>(target: T, value: T): Function | ||
export function increment(target: number, amount?: number): Function | ||
export function merge<T>(target: T, value: Partial<T>): Function | ||
export function pop(target: any[]): Function | ||
export function push<T>(target: Array<T>, value: T): Function | ||
export function set<T>(target: T, value: T): Function | ||
export function shift(target: any[]): Function | ||
export function splice( | ||
target: Tag, | ||
target: any[], | ||
start: number, | ||
deleteCount?: number | ||
): Function | ||
export function toggle(target: Tag): Function | ||
export function unset(target: Tag): Function | ||
export function unshift(target: Tag): Function | ||
export function toggle(target: boolean): Function | ||
export function unset(target: any): Function | ||
export function unshift<T>(target: Array<T>, value: T): Function | ||
export function equals(value: Tag): Function | ||
export function equals(value: string | number): Function | ||
export function wait(time: number): Function | ||
export function when(value: Tag): Function | ||
export function when<A>( | ||
value: Tag<A> | A, | ||
check: (value: A) => boolean | ||
export function when(value: any): Function | ||
export function when<T>( | ||
value: T, | ||
check: (value: T) => boolean | ||
): Function | ||
export function when<A, B>( | ||
value1: Tag<A> | A, | ||
value2: Tag<B> | B, | ||
value1: A, | ||
value2: B, | ||
check: (value1: A, value2: B) => boolean | ||
): Function | ||
export function when<A, B, C>( | ||
value1: Tag<A> | A, | ||
value2: Tag<B> | B, | ||
value3: Tag<C> | C, | ||
value1: A, | ||
value2: B, | ||
value3: C, | ||
check: (value1: A, value2: B, value3: C) => boolean | ||
): Function | ||
export function when(value: Tag, ...args: any[]): Function | ||
export function when(...args: any[]): Function |
@@ -39,12 +39,12 @@ import { DevTools } from './devtools'; | ||
concat<T>(path: T, arr: T): void; | ||
increment(path: any, amount?: number): void; | ||
increment(path: number, amount?: number): void; | ||
merge<T>(path: T, obj: Partial<T>): void; | ||
pop(path: any[]): void; | ||
push<T>(path: T, value: any): void; | ||
push<T>(path: Array<T>, value: T): void; | ||
set<T>(path: T, value: T): void; | ||
shift<T>(path: any[]): void; | ||
splice<T>(path: any[], ...args: number[]): void; | ||
shift(path: any[]): void; | ||
splice(path: any[], ...args: number[]): void; | ||
toggle(path: boolean): void; | ||
unset(path: any): void; | ||
unshift<T>(path: T, value: any): void; | ||
unshift<T>(path: Array<T>, value: T): void; | ||
} | ||
@@ -103,3 +103,3 @@ | ||
type ModuleFunction<State, Sequences, Computed> = ( | ||
module: { name: string; path: string; controller: ControllerClass } | ||
module: { name: string; path: string; app: ControllerClass } | ||
) => ModuleObjectDefinition<State, Sequences, Computed>; | ||
@@ -136,5 +136,6 @@ | ||
getModel(): StateModel; | ||
getState(path?: string): any; | ||
runSignal(name: string, signal: Sequence, payload: any): void; | ||
getSignal<T = any>(path: string): RunableSequence<T>; | ||
getState(path?: string): any; | ||
get<T>(value: T): T | ||
runSequence(name: string, signal: Sequence, payload: any): void; | ||
getSequence<T = any>(path: string): RunableSequence<T>; | ||
addModule(path: string, module: ModuleClass): void; | ||
@@ -141,0 +142,0 @@ removeModule(path: string): void; |
@@ -63,3 +63,5 @@ 'use strict'; | ||
_options$preventIniti = options.preventInitialize, | ||
preventInitialize = _options$preventIniti === undefined ? false : _options$preventIniti; | ||
preventInitialize = _options$preventIniti === undefined ? false : _options$preventIniti, | ||
_options$returnSequen = options.returnSequencePromise, | ||
returnSequencePromise = _options$returnSequen === undefined ? false : _options$returnSequen; | ||
@@ -79,2 +81,3 @@ | ||
_this.throwToConsole = throwToConsole; | ||
_this.returnSequencePromise = returnSequencePromise; | ||
@@ -196,3 +199,3 @@ _this.devtools = devtools; | ||
this.run(name, sequence, payload, function (error) { | ||
var callback = function callback(error) { | ||
if (error) { | ||
@@ -261,3 +264,9 @@ var sequencePath = (0, _utils.ensurePath)(error.execution.name); | ||
} | ||
}); | ||
}; | ||
if (this.returnSequencePromise) { | ||
return this.run(name, sequence, payload).catch(callback); | ||
} else { | ||
this.run(name, sequence, payload, callback); | ||
} | ||
} | ||
@@ -264,0 +273,0 @@ /* |
@@ -10,2 +10,4 @@ 'use strict'; | ||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; | ||
var _functionTree = require('function-tree'); | ||
@@ -83,2 +85,11 @@ | ||
}, { | ||
key: 'subscribe', | ||
value: function subscribe(watcher, cb) { | ||
if (!this.watcherSubscription) { | ||
this.watcherSubscription = _get(Computed.prototype.__proto__ || Object.getPrototypeOf(Computed.prototype), 'subscribe', this).call(this, this, this.onSubscription); | ||
} | ||
return _get(Computed.prototype.__proto__ || Object.getPrototypeOf(Computed.prototype), 'subscribe', this).call(this, watcher, cb); | ||
} | ||
}, { | ||
key: 'onSubscription', | ||
@@ -85,0 +96,0 @@ value: function onSubscription() { |
@@ -81,3 +81,3 @@ 'use strict'; | ||
_this.version = "5.0.0-1527015081471"; | ||
_this.version = "5.0.0-1527107988207"; | ||
_this.debuggerWatchMap = {}; | ||
@@ -84,0 +84,0 @@ _this.debuggerComputedMap = {}; |
@@ -10,9 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.concat: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.concat: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].concat(context.resolve.path(target), context.resolve.value(value)); | ||
context.store.concat(target, value); | ||
} | ||
concat.displayName = 'operator.concat(' + String(target) + ', ' + String(value) + ')'; | ||
concat.displayName = 'factory.concat(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -19,0 +19,0 @@ return concat; |
@@ -12,3 +12,3 @@ 'use strict'; | ||
if (!resolve.isTag(target, 'state', 'props', 'moduleState')) { | ||
throw new Error('Cerebral operator.equals: You have to use the STATE, PROPS or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.equals: You have to use the STATE, PROPS or MODULESTATE tag as first argument'); | ||
} | ||
@@ -21,3 +21,3 @@ | ||
equals.displayName = 'operator.equals(' + String(target) + ')'; | ||
equals.displayName = 'factory.equals(' + String(target) + ')'; | ||
@@ -24,0 +24,0 @@ return equals; |
@@ -11,3 +11,3 @@ 'use strict'; | ||
function increment(_ref) { | ||
var state = _ref.state, | ||
var store = _ref.store, | ||
module = _ref.module, | ||
@@ -18,3 +18,3 @@ props = _ref.props, | ||
if (!resolve.isTag(target, 'state', 'props', 'moduleState')) { | ||
throw new Error('Cerebral operator.increment: You have to use the STATE, MODULE or PROPS tag as first argument'); | ||
throw new Error('Cerebral factory.increment: You have to use the STATE, MODULESTATE or PROPS tag as first argument'); | ||
} | ||
@@ -25,10 +25,8 @@ | ||
if (!Number.isInteger(resolvedValue)) { | ||
throw new Error('Cerebral operator.increment: You must increment by integer values'); | ||
throw new Error('Cerebral factory.increment: You must increment by integer values'); | ||
} | ||
var invalidStateMsg = 'Cerebral operator.increment: You must increment integer values'; | ||
if (target.type === 'state') { | ||
state.increment(resolve.path(target), resolvedValue); | ||
} else if (target.type === 'moduleState') { | ||
module.increment(resolve.path(target), resolvedValue); | ||
var invalidStateMsg = 'Cerebral factory.increment: You must increment integer values'; | ||
if (target.type === 'state' || target.type === 'moduleState') { | ||
store.increment(target, resolvedValue); | ||
} else { | ||
@@ -52,3 +50,3 @@ var result = Object.assign({}, props); | ||
increment.displayName = 'operator.increment(' + String(target) + ', ' + String(value) + ')'; | ||
increment.displayName = 'factory.increment(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -55,0 +53,0 @@ return increment; |
@@ -7,2 +7,17 @@ 'use strict'; | ||
var _functionTree = require('function-tree'); | ||
Object.defineProperty(exports, 'sequence', { | ||
enumerable: true, | ||
get: function get() { | ||
return _functionTree.sequence; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'parallel', { | ||
enumerable: true, | ||
get: function get() { | ||
return _functionTree.parallel; | ||
} | ||
}); | ||
var _debounce = require('./debounce'); | ||
@@ -9,0 +24,0 @@ |
@@ -13,9 +13,9 @@ 'use strict'; | ||
function merge(context) { | ||
var _context$target$type; | ||
var _context$store; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.merge: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.merge: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
(_context$target$type = context[target.type]).merge.apply(_context$target$type, [context.resolve.path(target)].concat(_toConsumableArray(values.map(function (value) { | ||
(_context$store = context.store).merge.apply(_context$store, [target].concat(_toConsumableArray(values.map(function (value) { | ||
if (context.resolve.isTag(value)) { | ||
@@ -33,3 +33,3 @@ return context.resolve.value(value); | ||
merge.displayName = 'operator.merge(' + String(target) + ', ' + values.map(function (value) { | ||
merge.displayName = 'factory.merge(' + String(target) + ', ' + values.map(function (value) { | ||
return String(value); | ||
@@ -36,0 +36,0 @@ }).join(',') + ')'; |
@@ -10,9 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.pop: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.pop: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].pop(context.resolve.path(target)); | ||
context.store.pop(target); | ||
} | ||
pop.displayName = 'operator.pop(' + String(target) + ')'; | ||
pop.displayName = 'factory.pop(' + String(target) + ')'; | ||
@@ -19,0 +19,0 @@ return pop; |
@@ -10,9 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.push: You have to use the STATE TAG as first argument'); | ||
throw new Error('Cerebral factory.push: You have to use the STATE TAG as first argument'); | ||
} | ||
context[target.type].push(context.resolve.path(target), context.resolve.value(value)); | ||
context.store.push(target, value); | ||
} | ||
push.displayName = 'operator.push(' + String(target) + ')'; | ||
push.displayName = 'factory.push(' + String(target) + ')'; | ||
@@ -19,0 +19,0 @@ return push; |
@@ -9,4 +9,3 @@ 'use strict'; | ||
function set(_ref) { | ||
var state = _ref.state, | ||
module = _ref.module, | ||
var store = _ref.store, | ||
props = _ref.props, | ||
@@ -16,3 +15,3 @@ resolve = _ref.resolve; | ||
if (!resolve.isTag(target, 'state', 'props', 'moduleState')) { | ||
throw new Error('Cerebral operator.set: You have to use the STATE, PROPS or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.set: You have to use the STATE, PROPS or MODULESTATE tag as first argument'); | ||
} | ||
@@ -29,5 +28,3 @@ | ||
if (target.type === 'state') { | ||
state.set(resolve.path(target), resolvedValue); | ||
} else if (target.type === 'moduleState') { | ||
module.set(resolve.path(target), resolvedValue); | ||
store.set(target, resolvedValue); | ||
} else { | ||
@@ -46,3 +43,3 @@ var result = Object.assign({}, props); | ||
set.displayName = 'operator.set(' + String(target) + ', ' + String(value) + ')'; | ||
set.displayName = 'factory.set(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -49,0 +46,0 @@ return set; |
@@ -10,9 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.shift: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.shift: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].shift(context.resolve.path(target)); | ||
context.store.shift(target); | ||
} | ||
shift.displayName = 'operator.shift(' + String(target) + ')'; | ||
shift.displayName = 'factory.shift(' + String(target) + ')'; | ||
@@ -19,0 +19,0 @@ return shift; |
@@ -13,16 +13,12 @@ 'use strict'; | ||
function splice(context) { | ||
var _context$target$type; | ||
var _context$store; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.splice: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.splice: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
var spliceArgs = args.map(function (arg) { | ||
return context.resolve.value(arg); | ||
}); | ||
(_context$target$type = context[target.type]).splice.apply(_context$target$type, [context.resolve.path(target)].concat(_toConsumableArray(spliceArgs))); | ||
(_context$store = context.store).splice.apply(_context$store, [target].concat(args)); | ||
} | ||
splice.displayName = 'operator.splice(' + String(target) + ', ' + args.map(function (arg) { | ||
splice.displayName = 'factory.splice(' + String(target) + ', ' + args.map(function (arg) { | ||
return String(arg); | ||
@@ -33,4 +29,2 @@ }).join(',') + ')'; | ||
}; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
//# sourceMappingURL=splice.js.map |
@@ -10,11 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.toggle: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.toggle: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
var path = context.resolve.path(target); | ||
context[target.type].toggle(path); | ||
context.store.toggle(target); | ||
} | ||
toggle.displayName = 'operator.toggle(' + String(target) + ')'; | ||
toggle.displayName = 'factory.toggle(' + String(target) + ')'; | ||
@@ -21,0 +19,0 @@ return toggle; |
@@ -10,9 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.unset: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.unset: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].unset(context.resolve.path(target)); | ||
context.store.unset(target); | ||
} | ||
unset.displayName = 'operator.unset(' + String(target) + ')'; | ||
unset.displayName = 'factory.unset(' + String(target) + ')'; | ||
@@ -19,0 +19,0 @@ return unset; |
@@ -10,9 +10,9 @@ 'use strict'; | ||
if (!context.resolve.isTag(target, 'state', 'moduleState')) { | ||
throw new Error('Cerebral operator.unshift: You have to use the STATE or MODULE tag as first argument'); | ||
throw new Error('Cerebral factory.unshift: You have to use the STATE or MODULESTATE tag as first argument'); | ||
} | ||
context[target.type].unshift(context.resolve.path(target), context.resolve.value(value)); | ||
context.store.unshift(target, value); | ||
} | ||
unshift.displayName = 'operator.unshift(' + String(target) + ', ' + String(value) + ')'; | ||
unshift.displayName = 'factory.unshift(' + String(target) + ', ' + String(value) + ')'; | ||
@@ -19,0 +19,0 @@ return unshift; |
@@ -25,6 +25,6 @@ 'use strict'; | ||
if (valueTemplates.length > 0 && !(valueTemplates[0] instanceof _tags.Tag)) { | ||
throw new Error('Cerebral operator.when: You have to use the STATE, MODULE or PROPS tag as values, see: ' + HELP_URL); | ||
throw new Error('Cerebral factory.when: You have to use the STATE, MODULESTATE or PROPS tag as values, see: ' + HELP_URL); | ||
} | ||
if (!path || !path.true || !path.false) { | ||
throw new Error('Cerebral operator.when: true/false paths need to be provided, see: http://cerebraljs.com/docs/api/factories.html#when'); | ||
throw new Error('Cerebral factory.when: true/false paths need to be provided, see: http://cerebraljs.com/docs/api/factories.html#when'); | ||
} | ||
@@ -39,3 +39,3 @@ var values = valueTemplates.map(function (value) { | ||
when.displayName = 'operator.when(' + args.filter(function (arg) { | ||
when.displayName = 'factory.when(' + args.filter(function (arg) { | ||
return typeof arg !== 'function'; | ||
@@ -42,0 +42,0 @@ }).map(function (arg) { |
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.throwError = exports.createDummyController = exports.View = exports.parallel = exports.sequence = exports.Reaction = exports.Computed = exports.Provider = exports.CerebralError = exports.ChainSequenceWithPropsFactory = exports.ChainSequenceFactory = exports.BaseControllerClass = exports.ProviderClass = exports.ControllerClass = exports.ModuleClass = undefined; | ||
exports.throwError = exports.createDummyController = exports.View = exports.Reaction = exports.Computed = exports.Provider = exports.CerebralError = exports.ChainSequenceWithPropsFactory = exports.ChainSequenceFactory = exports.BaseControllerClass = exports.ProviderClass = exports.ControllerClass = exports.ModuleClass = undefined; | ||
@@ -97,17 +97,2 @@ var _Module = require('./Module'); | ||
var _functionTree = require('function-tree'); | ||
Object.defineProperty(exports, 'sequence', { | ||
enumerable: true, | ||
get: function get() { | ||
return _functionTree.sequence; | ||
} | ||
}); | ||
Object.defineProperty(exports, 'parallel', { | ||
enumerable: true, | ||
get: function get() { | ||
return _functionTree.parallel; | ||
} | ||
}); | ||
var _View = require('./View'); | ||
@@ -114,0 +99,0 @@ |
@@ -31,3 +31,3 @@ 'use strict'; | ||
var moduleStub = { | ||
controller: controller, | ||
app: controller, | ||
path: stringPath, | ||
@@ -52,3 +52,3 @@ name: path.slice().pop() | ||
run: function run(payload) { | ||
controller.runSequence(path.concat(sequenceKey).join('.'), sequence, payload); | ||
return controller.runSequence(path.concat(sequenceKey).join('.'), sequence, payload); | ||
} | ||
@@ -55,0 +55,0 @@ }; |
@@ -11,2 +11,4 @@ 'use strict'; | ||
var _2 = _interopRequireDefault(_); | ||
var _functionTree = require('function-tree'); | ||
@@ -18,2 +20,4 @@ | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
@@ -158,3 +162,3 @@ | ||
this.controller = (0, _.Controller)(rootModule, { | ||
this.controller = (0, _2.default)(rootModule, { | ||
devtools: new SnapshotDevtool({ | ||
@@ -161,0 +165,0 @@ host: 'local' |
{ | ||
"name": "cerebral", | ||
"version": "5.0.0-1527015081471", | ||
"version": "5.0.0-1527107988207", | ||
"description": "A state controller with its own debugger", | ||
@@ -24,3 +24,3 @@ "main": "index.js", | ||
"es6-error": "^4.0.2", | ||
"function-tree": "^3.3.0-1527015081471" | ||
"function-tree": "^3.3.0-1527107988207" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
@@ -7,2 +7,3 @@ import { | ||
ControllerOptions, | ||
ModuleDefinition, | ||
} from '../' | ||
@@ -20,3 +21,3 @@ | ||
export function Snapshot(module: ModuleClass): SnapshotTest | ||
export function Snapshot(module: ModuleDefinition): SnapshotTest | ||
@@ -50,3 +51,3 @@ export interface RunActionResult<P, T> { | ||
export function runCompute<T>(computed: Computed<T>, fixtures?: any): T | ||
export function runCompute<T>(computed: T, fixtures?: any): T | ||
@@ -53,0 +54,0 @@ export function runSignal<P, T0>( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7599
0.26%764551
-0.07%