Comparing version 1.0.0-1532124883785 to 1.0.0-1532192714446
import Devtools from './Devtools'; | ||
import { IValueAction, INoValueAction } from './Action'; | ||
export { default as compose } from './compose'; | ||
export { default as namespaces, Namespace } from './namespaces'; | ||
export { default as derived } from './derived'; | ||
@@ -41,3 +41,3 @@ export { default as computed } from './computed'; | ||
export default class App<State extends object, Providers extends object, Actions extends { | ||
[namespace: string]: ActionsCallback<Providers, State>; | ||
[namespace: string]: ActionsCallback<{}, {}>; | ||
} | ActionsCallback<Providers, State>> { | ||
@@ -47,3 +47,3 @@ private proxyStateTree; | ||
actions: Actions extends { | ||
[namespace: string]: ActionsCallback<Providers, State>; | ||
[namespace: string]: ActionsCallback<{}, {}>; | ||
} ? { | ||
@@ -50,0 +50,0 @@ [Namespace in keyof Actions]: ReturnType<Actions[Namespace]>; |
@@ -6,3 +6,3 @@ import { ActionChain } from 'action-chain'; | ||
import Action from './Action'; | ||
export { default as compose } from './compose'; | ||
export { default as namespaces } from './namespaces'; | ||
export { default as derived } from './derived'; | ||
@@ -9,0 +9,0 @@ export { default as computed } from './computed'; |
@@ -1,2 +0,2 @@ | ||
import App, { compose } from './'; | ||
import App, { namespaces } from './'; | ||
describe('Overmind', () => { | ||
@@ -21,4 +21,4 @@ test('should instantiate app with state', () => { | ||
}); | ||
test('should instantiate app with composed state and actions', () => { | ||
const config = compose({ | ||
test('should instantiate app with namespaces', () => { | ||
const config = namespaces({ | ||
foo: { | ||
@@ -47,2 +47,21 @@ state: { | ||
}); | ||
test('should allow namespaced modules to be functions', () => { | ||
const fooNamespace = (namespace) => { | ||
const state = { | ||
foo: 'bar', | ||
}; | ||
return { | ||
state, | ||
actions: (action) => ({ | ||
foo: action().map((value, { state }) => value + state[namespace].foo), | ||
}), | ||
}; | ||
}; | ||
const config = namespaces({ | ||
foo: fooNamespace, | ||
}); | ||
const app = new App(config); | ||
expect(app.state.foo.foo).toEqual('bar'); | ||
expect(app.actions.foo.foo('mip')).toEqual('mipbar'); | ||
}); | ||
}); | ||
@@ -49,0 +68,0 @@ describe('OPERATORS', () => { |
import Devtools from './Devtools'; | ||
import { IValueAction, INoValueAction } from './Action'; | ||
export { default as compose } from './compose'; | ||
export { default as namespaces, Namespace } from './namespaces'; | ||
export { default as derived } from './derived'; | ||
@@ -41,3 +41,3 @@ export { default as computed } from './computed'; | ||
export default class App<State extends object, Providers extends object, Actions extends { | ||
[namespace: string]: ActionsCallback<Providers, State>; | ||
[namespace: string]: ActionsCallback<{}, {}>; | ||
} | ActionsCallback<Providers, State>> { | ||
@@ -47,3 +47,3 @@ private proxyStateTree; | ||
actions: Actions extends { | ||
[namespace: string]: ActionsCallback<Providers, State>; | ||
[namespace: string]: ActionsCallback<{}, {}>; | ||
} ? { | ||
@@ -50,0 +50,0 @@ [Namespace in keyof Actions]: ReturnType<Actions[Namespace]>; |
@@ -8,4 +8,4 @@ "use strict"; | ||
const Action_1 = require("./Action"); | ||
var compose_1 = require("./compose"); | ||
exports.compose = compose_1.default; | ||
var namespaces_1 = require("./namespaces"); | ||
exports.namespaces = namespaces_1.default; | ||
var derived_1 = require("./derived"); | ||
@@ -12,0 +12,0 @@ exports.derived = derived_1.default; |
@@ -23,4 +23,4 @@ "use strict"; | ||
}); | ||
test('should instantiate app with composed state and actions', () => { | ||
const config = _1.compose({ | ||
test('should instantiate app with namespaces', () => { | ||
const config = _1.namespaces({ | ||
foo: { | ||
@@ -49,2 +49,21 @@ state: { | ||
}); | ||
test('should allow namespaced modules to be functions', () => { | ||
const fooNamespace = (namespace) => { | ||
const state = { | ||
foo: 'bar', | ||
}; | ||
return { | ||
state, | ||
actions: (action) => ({ | ||
foo: action().map((value, { state }) => value + state[namespace].foo), | ||
}), | ||
}; | ||
}; | ||
const config = _1.namespaces({ | ||
foo: fooNamespace, | ||
}); | ||
const app = new _1.default(config); | ||
expect(app.state.foo.foo).toEqual('bar'); | ||
expect(app.actions.foo.foo('mip')).toEqual('mipbar'); | ||
}); | ||
}); | ||
@@ -51,0 +70,0 @@ describe('OPERATORS', () => { |
{ | ||
"name": "overmind", | ||
"version": "1.0.0-1532124883785", | ||
"version": "1.0.0-1532192714446", | ||
"description": "Functional actions", | ||
@@ -36,6 +36,6 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>", | ||
"@types/node": "^10.5.1", | ||
"action-chain": "1.0.0-1532124883785", | ||
"action-chain": "1.0.0-1532192714446", | ||
"is-plain-object": "^2.0.4", | ||
"betsy": "1.0.0-1532124883785", | ||
"proxy-state-tree": "1.0.0-1532124883785", | ||
"betsy": "1.0.0-1532192714446", | ||
"proxy-state-tree": "1.0.0-1532192714446", | ||
"tslib": "^1.9.3" | ||
@@ -42,0 +42,0 @@ }, |
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
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
240887
2235
+ Addedaction-chain@1.0.0-1532192714446(transitive)
+ Addedbetsy@1.0.0-1532192714446(transitive)
+ Addedproxy-state-tree@1.0.0-1532192714446(transitive)
- Removedaction-chain@1.0.0-1532124883785(transitive)
- Removedbetsy@1.0.0-1532124883785(transitive)
- Removedproxy-state-tree@1.0.0-1532124883785(transitive)
Updatedbetsy@1.0.0-1532192714446