Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

businessman

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

businessman - npm Package Compare versions

Comparing version 1.5.1 to 2.0.0

.github/CONTRIBUTING.md

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v2.0.0
- Remove: Store style API [Issue #8](https://github.com/businessmanjs/businessman/issues/8)
# v1.5.1

@@ -2,0 +6,0 @@

48

dist/businessman.amd.js

@@ -96,3 +96,3 @@ define(['exports'], function (exports) { 'use strict';

var getters$1 = {
var getters = {
default: function (state) { return state; }

@@ -109,3 +109,3 @@ };

var actions$$1 = opt.actions; if ( actions$$1 === void 0 ) actions$$1 = {};
var getters = opt.getters; if ( getters === void 0 ) getters = {};
var getters$$1 = opt.getters; if ( getters$$1 === void 0 ) getters$$1 = {};
var type = opt.type;

@@ -125,3 +125,3 @@ var store = this;

};
getters = assign( getters, getters$1 );
getters$$1 = assign( getters$$1, getters );
mutations$$1 = assign( mutations$$1, mutations );

@@ -138,3 +138,3 @@ actions$$1 = assign( actions$$1, actions );

getters: {
value: getters,
value: getters$$1,
configurable: false,

@@ -207,13 +207,5 @@ writable: false

var INIT = 'INIT';
var CREATE_CLIENT_STORE = 'CREATE_CLIENT_STORE';
var CREATE_CLIENT_MANAGER = 'CREATE_CLIENT_MANAGER';
var stores = {};
var managers = {};
var getters = {};
var forClient = {
stores: [],
managers: [],
getters: []
};

@@ -241,3 +233,3 @@ var worker = {

};
postMessage( pack( { type: INIT, payload: { stores: forClient.stores, managers: forClient.managers, getters: forClient.getters } } ) );
postMessage( pack( { type: INIT, payload: { stores: Object.keys( stores ), managers: Object.keys( managers ) } } ) );
},

@@ -247,10 +239,4 @@ registerStore: function (config) {

var type = store.type;
var actions = store.actions;
if ( !( type in stores ) ) {
stores[ type ] = store;
forClient.stores.push( {
type: type,
actions: Object.keys( actions ),
getters: Object.keys( getters )
} );
}

@@ -263,5 +249,2 @@ },

managers[ type ] = handler;
forClient.managers.push( {
type: type
} );
}

@@ -352,23 +335,2 @@ }

var onInit$1 = function () { return subscribe( INIT, function (data) {
var stores = {};
try {
data.stores.map( function (store) {
stores[ store.type ] = {
dispatch: function ( actionType, payload ) { return dispatch$1( store.type, actionType, payload ); },
subscribe: function (cb) { return subscribe( store.type, cb ); },
unsubscribe: function (cb) { return unsubscribe( store.type, cb ); },
getState: function ( getter, options ) { return getState$1( store.type, getter, options ); }
};
return store
} );
trigger( pack( { type: CREATE_CLIENT_STORE, payload: stores } ) );
trigger( pack( { type: CREATE_CLIENT_MANAGER, payload: data.managers } ) );
} catch ( err ) {
console.error( 'Error in creating client store or client manager', err );
}
} ); };
onInit$1();
exports.install = install;

@@ -375,0 +337,0 @@ exports.dispatch = dispatch$1;

@@ -94,3 +94,3 @@ var callbacks = {};

var getters$1 = {
var getters = {
default: function (state) { return state; }

@@ -107,3 +107,3 @@ };

var actions$$1 = opt.actions; if ( actions$$1 === void 0 ) actions$$1 = {};
var getters = opt.getters; if ( getters === void 0 ) getters = {};
var getters$$1 = opt.getters; if ( getters$$1 === void 0 ) getters$$1 = {};
var type = opt.type;

@@ -123,3 +123,3 @@ var store = this;

};
getters = assign( getters, getters$1 );
getters$$1 = assign( getters$$1, getters );
mutations$$1 = assign( mutations$$1, mutations );

@@ -136,3 +136,3 @@ actions$$1 = assign( actions$$1, actions );

getters: {
value: getters,
value: getters$$1,
configurable: false,

@@ -205,13 +205,5 @@ writable: false

var INIT = 'INIT';
var CREATE_CLIENT_STORE = 'CREATE_CLIENT_STORE';
var CREATE_CLIENT_MANAGER = 'CREATE_CLIENT_MANAGER';
var stores = {};
var managers = {};
var getters = {};
var forClient = {
stores: [],
managers: [],
getters: []
};

@@ -239,3 +231,3 @@ var worker = {

};
postMessage( pack( { type: INIT, payload: { stores: forClient.stores, managers: forClient.managers, getters: forClient.getters } } ) );
postMessage( pack( { type: INIT, payload: { stores: Object.keys( stores ), managers: Object.keys( managers ) } } ) );
},

@@ -245,10 +237,4 @@ registerStore: function (config) {

var type = store.type;
var actions = store.actions;
if ( !( type in stores ) ) {
stores[ type ] = store;
forClient.stores.push( {
type: type,
actions: Object.keys( actions ),
getters: Object.keys( getters )
} );
}

@@ -261,5 +247,2 @@ },

managers[ type ] = handler;
forClient.managers.push( {
type: type
} );
}

@@ -350,23 +333,2 @@ }

var onInit$1 = function () { return subscribe( INIT, function (data) {
var stores = {};
try {
data.stores.map( function (store) {
stores[ store.type ] = {
dispatch: function ( actionType, payload ) { return dispatch$1( store.type, actionType, payload ); },
subscribe: function (cb) { return subscribe( store.type, cb ); },
unsubscribe: function (cb) { return unsubscribe( store.type, cb ); },
getState: function ( getter, options ) { return getState$1( store.type, getter, options ); }
};
return store
} );
trigger( pack( { type: CREATE_CLIENT_STORE, payload: stores } ) );
trigger( pack( { type: CREATE_CLIENT_MANAGER, payload: data.managers } ) );
} catch ( err ) {
console.error( 'Error in creating client store or client manager', err );
}
} ); };
onInit$1();
export { install, dispatch$1 as dispatch, operate, subscribe, unsubscribe, getState$1 as getState, getAllState, worker$1 as worker };

@@ -100,3 +100,3 @@ (function (global, factory) {

var getters$1 = {
var getters = {
default: function (state) { return state; }

@@ -113,3 +113,3 @@ };

var actions$$1 = opt.actions; if ( actions$$1 === void 0 ) actions$$1 = {};
var getters = opt.getters; if ( getters === void 0 ) getters = {};
var getters$$1 = opt.getters; if ( getters$$1 === void 0 ) getters$$1 = {};
var type = opt.type;

@@ -129,3 +129,3 @@ var store = this;

};
getters = assign( getters, getters$1 );
getters$$1 = assign( getters$$1, getters );
mutations$$1 = assign( mutations$$1, mutations );

@@ -142,3 +142,3 @@ actions$$1 = assign( actions$$1, actions );

getters: {
value: getters,
value: getters$$1,
configurable: false,

@@ -211,13 +211,5 @@ writable: false

var INIT = 'INIT';
var CREATE_CLIENT_STORE = 'CREATE_CLIENT_STORE';
var CREATE_CLIENT_MANAGER = 'CREATE_CLIENT_MANAGER';
var stores = {};
var managers = {};
var getters = {};
var forClient = {
stores: [],
managers: [],
getters: []
};

@@ -245,3 +237,3 @@ var worker = {

};
postMessage( pack( { type: INIT, payload: { stores: forClient.stores, managers: forClient.managers, getters: forClient.getters } } ) );
postMessage( pack( { type: INIT, payload: { stores: Object.keys( stores ), managers: Object.keys( managers ) } } ) );
},

@@ -251,10 +243,4 @@ registerStore: function (config) {

var type = store.type;
var actions = store.actions;
if ( !( type in stores ) ) {
stores[ type ] = store;
forClient.stores.push( {
type: type,
actions: Object.keys( actions ),
getters: Object.keys( getters )
} );
}

@@ -267,5 +253,2 @@ },

managers[ type ] = handler;
forClient.managers.push( {
type: type
} );
}

@@ -356,23 +339,2 @@ }

var onInit$1 = function () { return subscribe( INIT, function (data) {
var stores = {};
try {
data.stores.map( function (store) {
stores[ store.type ] = {
dispatch: function ( actionType, payload ) { return dispatch$1( store.type, actionType, payload ); },
subscribe: function (cb) { return subscribe( store.type, cb ); },
unsubscribe: function (cb) { return unsubscribe( store.type, cb ); },
getState: function ( getter, options ) { return getState$1( store.type, getter, options ); }
};
return store
} );
trigger( pack( { type: CREATE_CLIENT_STORE, payload: stores } ) );
trigger( pack( { type: CREATE_CLIENT_MANAGER, payload: data.managers } ) );
} catch ( err ) {
console.error( 'Error in creating client store or client manager', err );
}
} ); };
onInit$1();
exports.install = install;

@@ -379,0 +341,0 @@ exports.dispatch = dispatch$1;

@@ -1,5 +0,1 @@

import onInit from './kick'
onInit()
export * from './src/businessman'
{
"name": "businessman",
"version": "1.5.1",
"version": "2.0.0",
"description": "Multi-thread State Management by the Worker API",

@@ -5,0 +5,0 @@ "main": "dist/businessman.js",

@@ -195,32 +195,25 @@ Multi-thread State Management by Worker API.

## Dispatch and Subscribe
### On initialization
```js
import { dispatch, subscribe } from 'businessman'
By subscribing `'INIT'` you can receive notification of installation.
dispatch( 'counter', 'increment', 1 )
Receives an array of store and manager types as payload.
subscribe( 'counter', state => {
console.log( state ) // 1
} )
```
Dispatch / Subscribe is also available in Store style.
```js
counter.dispatch( 'increment', 1 )
import { subscribe } from 'businessman'
counter.subscribe( state => {
console.log( state )
subscribe( 'INIT', data => {
console.log( data ) // { stores: [...], managers: [...] }
} )
```
The store style is available after the store in the worker has been created for the client. It can be obtained by subscribing `CREATE_CLIENT_STORE`.
## Dispatch and Subscribe
```js
let counter
import { dispatch, subscribe } from 'businessman'
subscribe( 'CREATE_CLIENT_STORE', stores => {
console.log( stores ) // { counter: { dispatch: function () {...}, subscribe: function () {...}, unsubscribe: function () {...}, getState: function () {...} } }
counter = stores.counter
dispatch( 'counter', 'increment', 1 )
subscribe( 'counter', state => {
console.log( state ) // 1
} )

@@ -240,9 +233,2 @@ ```

For store style ...
```js
counter.unsubscribe()
counter.unsubscribe( listener )
```
## getState

@@ -267,20 +253,5 @@

For store style ...
```js
counter.getState()
.then( state => {
console.log( state )
} )
// You can also specify Getter.
counter.getState( 'absolute' )
.then( state => {
console.log( state )
} )
```
## getAllState
getState() can only get the state of one store.
`getState()` can only get the state of one store.

@@ -302,2 +273,4 @@ To get the state of all stores, use `getAllState()`.

[GitHub Project](https://github.com/businessmanjs/businessman/issues)
[GitHub Issues](https://github.com/businessmanjs/businessman/issues)
[GitHub Contributing Guide](https://github.com/businessmanjs/businessman/blob/master/.github/CONTRIBUTING.md)
const INIT = 'INIT'
const CREATE_CLIENT_STORE = 'CREATE_CLIENT_STORE'
const CREATE_CLIENT_MANAGER = 'CREATE_CLIENT_MANAGER'
export {
INIT,
CREATE_CLIENT_STORE,
CREATE_CLIENT_MANAGER
}
export default INIT
import Store from './store/store'
import getAllState from './worker-get-all-state'
import { pack } from './util'
import { INIT } from './types/built-in'
import INIT from './types/built-in'
import { DISPATCH, OPERATE, GET_STATE, GET_ALL_STATE } from './types/api'

@@ -9,8 +9,2 @@

let managers = {}
let getters = {}
let forClient = {
stores: [],
managers: [],
getters: []
}

@@ -38,3 +32,3 @@ const worker = {

}
postMessage( pack( { type: INIT, payload: { stores: forClient.stores, managers: forClient.managers, getters: forClient.getters } } ) )
postMessage( pack( { type: INIT, payload: { stores: Object.keys( stores ), managers: Object.keys( managers ) } } ) )
},

@@ -44,12 +38,6 @@ registerStore: config => {

const {
type,
actions
type
} = store
if ( !( type in stores ) ) {
stores[ type ] = store
forClient.stores.push( {
type: type,
actions: Object.keys( actions ),
getters: Object.keys( getters )
} )
}

@@ -64,5 +52,2 @@ },

managers[ type ] = handler
forClient.managers.push( {
type: type
} )
}

@@ -69,0 +54,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc