businessman
Advanced tools
Comparing version 1.4.6 to 1.4.7
@@ -129,19 +129,34 @@ define(['exports'], function (exports) { 'use strict'; | ||
var o = new function () { | ||
var CLIENT = new function () { | ||
observable( this ); | ||
}(); | ||
var GETTER = new function () { | ||
observable( this ); | ||
}(); | ||
var observer = function (obs) { | ||
var target; | ||
switch ( obs ) { | ||
case 'getter': | ||
target = GETTER; | ||
break | ||
default: | ||
target = CLIENT; | ||
break | ||
} | ||
return target | ||
}; | ||
var trigger = function ( data ) { | ||
o.trigger( data.type, data.payload, data.mutation, data.getter ); | ||
var trigger = function ( data, obs ) { | ||
observer( obs ).trigger( data.type, data.payload, data.mutation, data.getter ); | ||
}; | ||
var on = function ( type, cb ) { | ||
o.on( type, cb ); | ||
var on = function ( type, cb, obs ) { | ||
observer( obs ).on( type, cb ); | ||
}; | ||
var off = function ( type, cb ) { | ||
var off = function ( type, cb, obs ) { | ||
if ( cb ) { | ||
o.off( type, cb ); | ||
observer( obs ).off( type, cb ); | ||
} else { | ||
o.off( type ); | ||
observer( obs ).off( type ); | ||
} | ||
@@ -327,3 +342,3 @@ }; | ||
worker = new Worker( path ); | ||
worker.onmessage = function (message) { return trigger( message.data ); }; | ||
worker.onmessage = function (m) { return trigger( m.data, ( m.data.getter ? 'getter' : 'client' ) ); }; | ||
return worker | ||
@@ -343,10 +358,12 @@ } catch ( err ) { | ||
var subscribe$1 = function ( type, cb ) { | ||
var _subscribe = function ( type, cb ) { | ||
on( type, cb ); | ||
}; | ||
var unsubscribe$1 = function ( type, cb ) { | ||
var _unsubscribe = function ( type, cb ) { | ||
off( type, cb ); | ||
}; | ||
var observer$1 = 'getter'; | ||
var _getState = function ( storeType, getter, options, worker ) { | ||
@@ -360,7 +377,7 @@ if ( getter === void 0 ) getter = 'default'; | ||
} | ||
unsubscribe$1( storeType, subscriber ); | ||
off( storeType, subscriber, observer$1 ); | ||
resolve( state ); | ||
}; | ||
subscribe$1( storeType, subscriber ); | ||
on( storeType, subscriber, observer$1 ); | ||
@@ -370,3 +387,3 @@ try { | ||
} catch ( err ) { | ||
unsubscribe$1( storeType, subscriber ); | ||
off( storeType, subscriber, observer$1 ); | ||
reject( err ); | ||
@@ -384,4 +401,4 @@ } | ||
var operate = function ( managerType, payload ) { return _operate( managerType, payload, businessmanWoker ); }; | ||
var subscribe = function ( type, cb ) { return subscribe$1( type, cb ); }; | ||
var unsubscribe = function ( type, cb ) { return unsubscribe$1( type, cb ); }; | ||
var subscribe = function ( type, cb ) { return _subscribe( type, cb ); }; | ||
var unsubscribe = function ( type, cb ) { return _unsubscribe( type, cb ); }; | ||
var getState$1 = function ( storeType, getter, options ) { return _getState( storeType, getter, options, businessmanWoker ); }; | ||
@@ -388,0 +405,0 @@ |
@@ -127,19 +127,34 @@ var observable = function(el) { | ||
var o = new function () { | ||
var CLIENT = new function () { | ||
observable( this ); | ||
}(); | ||
var GETTER = new function () { | ||
observable( this ); | ||
}(); | ||
var observer = function (obs) { | ||
var target; | ||
switch ( obs ) { | ||
case 'getter': | ||
target = GETTER; | ||
break | ||
default: | ||
target = CLIENT; | ||
break | ||
} | ||
return target | ||
}; | ||
var trigger = function ( data ) { | ||
o.trigger( data.type, data.payload, data.mutation, data.getter ); | ||
var trigger = function ( data, obs ) { | ||
observer( obs ).trigger( data.type, data.payload, data.mutation, data.getter ); | ||
}; | ||
var on = function ( type, cb ) { | ||
o.on( type, cb ); | ||
var on = function ( type, cb, obs ) { | ||
observer( obs ).on( type, cb ); | ||
}; | ||
var off = function ( type, cb ) { | ||
var off = function ( type, cb, obs ) { | ||
if ( cb ) { | ||
o.off( type, cb ); | ||
observer( obs ).off( type, cb ); | ||
} else { | ||
o.off( type ); | ||
observer( obs ).off( type ); | ||
} | ||
@@ -325,3 +340,3 @@ }; | ||
worker = new Worker( path ); | ||
worker.onmessage = function (message) { return trigger( message.data ); }; | ||
worker.onmessage = function (m) { return trigger( m.data, ( m.data.getter ? 'getter' : 'client' ) ); }; | ||
return worker | ||
@@ -341,10 +356,12 @@ } catch ( err ) { | ||
var subscribe$1 = function ( type, cb ) { | ||
var _subscribe = function ( type, cb ) { | ||
on( type, cb ); | ||
}; | ||
var unsubscribe$1 = function ( type, cb ) { | ||
var _unsubscribe = function ( type, cb ) { | ||
off( type, cb ); | ||
}; | ||
var observer$1 = 'getter'; | ||
var _getState = function ( storeType, getter, options, worker ) { | ||
@@ -358,7 +375,7 @@ if ( getter === void 0 ) getter = 'default'; | ||
} | ||
unsubscribe$1( storeType, subscriber ); | ||
off( storeType, subscriber, observer$1 ); | ||
resolve( state ); | ||
}; | ||
subscribe$1( storeType, subscriber ); | ||
on( storeType, subscriber, observer$1 ); | ||
@@ -368,3 +385,3 @@ try { | ||
} catch ( err ) { | ||
unsubscribe$1( storeType, subscriber ); | ||
off( storeType, subscriber, observer$1 ); | ||
reject( err ); | ||
@@ -382,4 +399,4 @@ } | ||
var operate = function ( managerType, payload ) { return _operate( managerType, payload, businessmanWoker ); }; | ||
var subscribe = function ( type, cb ) { return subscribe$1( type, cb ); }; | ||
var unsubscribe = function ( type, cb ) { return unsubscribe$1( type, cb ); }; | ||
var subscribe = function ( type, cb ) { return _subscribe( type, cb ); }; | ||
var unsubscribe = function ( type, cb ) { return _unsubscribe( type, cb ); }; | ||
var getState$1 = function ( storeType, getter, options ) { return _getState( storeType, getter, options, businessmanWoker ); }; | ||
@@ -386,0 +403,0 @@ |
@@ -133,19 +133,34 @@ (function (global, factory) { | ||
var o = new function () { | ||
var CLIENT = new function () { | ||
observable( this ); | ||
}(); | ||
var GETTER = new function () { | ||
observable( this ); | ||
}(); | ||
var observer = function (obs) { | ||
var target; | ||
switch ( obs ) { | ||
case 'getter': | ||
target = GETTER; | ||
break | ||
default: | ||
target = CLIENT; | ||
break | ||
} | ||
return target | ||
}; | ||
var trigger = function ( data ) { | ||
o.trigger( data.type, data.payload, data.mutation, data.getter ); | ||
var trigger = function ( data, obs ) { | ||
observer( obs ).trigger( data.type, data.payload, data.mutation, data.getter ); | ||
}; | ||
var on = function ( type, cb ) { | ||
o.on( type, cb ); | ||
var on = function ( type, cb, obs ) { | ||
observer( obs ).on( type, cb ); | ||
}; | ||
var off = function ( type, cb ) { | ||
var off = function ( type, cb, obs ) { | ||
if ( cb ) { | ||
o.off( type, cb ); | ||
observer( obs ).off( type, cb ); | ||
} else { | ||
o.off( type ); | ||
observer( obs ).off( type ); | ||
} | ||
@@ -331,3 +346,3 @@ }; | ||
worker = new Worker( path ); | ||
worker.onmessage = function (message) { return trigger( message.data ); }; | ||
worker.onmessage = function (m) { return trigger( m.data, ( m.data.getter ? 'getter' : 'client' ) ); }; | ||
return worker | ||
@@ -347,10 +362,12 @@ } catch ( err ) { | ||
var subscribe$1 = function ( type, cb ) { | ||
var _subscribe = function ( type, cb ) { | ||
on( type, cb ); | ||
}; | ||
var unsubscribe$1 = function ( type, cb ) { | ||
var _unsubscribe = function ( type, cb ) { | ||
off( type, cb ); | ||
}; | ||
var observer$1 = 'getter'; | ||
var _getState = function ( storeType, getter, options, worker ) { | ||
@@ -364,7 +381,7 @@ if ( getter === void 0 ) getter = 'default'; | ||
} | ||
unsubscribe$1( storeType, subscriber ); | ||
off( storeType, subscriber, observer$1 ); | ||
resolve( state ); | ||
}; | ||
subscribe$1( storeType, subscriber ); | ||
on( storeType, subscriber, observer$1 ); | ||
@@ -374,3 +391,3 @@ try { | ||
} catch ( err ) { | ||
unsubscribe$1( storeType, subscriber ); | ||
off( storeType, subscriber, observer$1 ); | ||
reject( err ); | ||
@@ -388,4 +405,4 @@ } | ||
var operate = function ( managerType, payload ) { return _operate( managerType, payload, businessmanWoker ); }; | ||
var subscribe = function ( type, cb ) { return subscribe$1( type, cb ); }; | ||
var unsubscribe = function ( type, cb ) { return unsubscribe$1( type, cb ); }; | ||
var subscribe = function ( type, cb ) { return _subscribe( type, cb ); }; | ||
var unsubscribe = function ( type, cb ) { return _unsubscribe( type, cb ); }; | ||
var getState$1 = function ( storeType, getter, options ) { return _getState( storeType, getter, options, businessmanWoker ); }; | ||
@@ -392,0 +409,0 @@ |
{ | ||
"name": "businessman", | ||
"version": "1.4.6", | ||
"version": "1.4.7", | ||
"description": "Multi-thread State Management by the Worker API", | ||
@@ -5,0 +5,0 @@ "main": "dist/businessman.js", |
@@ -1,4 +0,5 @@ | ||
import subscribe from './subscribe' | ||
import unsubscribe from './unsubscribe' | ||
import { on, off } from './util' | ||
const observer = 'getter' | ||
export default ( storeType, getter = 'default', options, worker ) => { | ||
@@ -10,7 +11,7 @@ return new Promise( ( resolve, reject ) => { | ||
} | ||
unsubscribe( storeType, subscriber ) | ||
off( storeType, subscriber, observer ) | ||
resolve( state ) | ||
} | ||
subscribe( storeType, subscriber ) | ||
on( storeType, subscriber, observer ) | ||
@@ -20,3 +21,3 @@ try { | ||
} catch ( err ) { | ||
unsubscribe( storeType, subscriber ) | ||
off( storeType, subscriber, observer ) | ||
reject( err ) | ||
@@ -23,0 +24,0 @@ } |
@@ -6,3 +6,3 @@ import { trigger } from './util' | ||
worker = new Worker( path ) | ||
worker.onmessage = message => trigger( message.data ) | ||
worker.onmessage = m => trigger( m.data, ( m.data.getter ? 'getter' : 'client' ) ) | ||
return worker | ||
@@ -9,0 +9,0 @@ } catch ( err ) { |
import observable from 'riot-observable' | ||
const o = new function () { | ||
const CLIENT = new function () { | ||
observable( this ) | ||
}() | ||
const GETTER = new function () { | ||
observable( this ) | ||
}() | ||
const observer = obs => { | ||
let target | ||
switch ( obs ) { | ||
case 'getter': | ||
target = GETTER | ||
break | ||
default: | ||
target = CLIENT | ||
break | ||
} | ||
return target | ||
} | ||
export const trigger = function ( data ) { | ||
o.trigger( data.type, data.payload, data.mutation, data.getter ) | ||
export const trigger = function ( data, obs ) { | ||
observer( obs ).trigger( data.type, data.payload, data.mutation, data.getter ) | ||
} | ||
export const on = function ( type, cb ) { | ||
o.on( type, cb ) | ||
export const on = function ( type, cb, obs ) { | ||
observer( obs ).on( type, cb ) | ||
} | ||
export const off = function ( type, cb ) { | ||
export const off = function ( type, cb, obs ) { | ||
if ( cb ) { | ||
o.off( type, cb ) | ||
observer( obs ).off( type, cb ) | ||
} else { | ||
o.off( type ) | ||
observer( obs ).off( type ) | ||
} | ||
@@ -21,0 +36,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
134203
1760