Comparing version 28.0.0-1614522025331 to 28.0.0-1614633297417
@@ -50,2 +50,19 @@ import { __awaiter } from "tslib"; | ||
}; | ||
const changeOptionalFoo = (context, newFoo) => { | ||
if (newFoo !== undefined) { | ||
context.state.foo = newFoo; | ||
} | ||
else { | ||
context.state.foo = 'default-foo'; | ||
} | ||
}; | ||
const asyncChangeOptionalFoo = (context, newFoo) => __awaiter(this, void 0, void 0, function* () { | ||
yield Promise.resolve(); | ||
if (newFoo !== undefined) { | ||
context.state.foo = newFoo; | ||
} | ||
else { | ||
context.state.foo = 'async-default-foo'; | ||
} | ||
}); | ||
const changeFormValue = (_, payload) => { | ||
@@ -68,2 +85,4 @@ const { form, key, value } = payload; | ||
rehydrateAction, | ||
changeOptionalFoo, | ||
asyncChangeOptionalFoo | ||
}; | ||
@@ -394,3 +413,16 @@ const effects = { | ||
}); | ||
test('should allow actions with optional parameter', () => __awaiter(void 0, void 0, void 0, function* () { | ||
const app = createDefaultOvermind(); | ||
app.actions.changeOptionalFoo(); | ||
expect(app.state.foo).toBe('default-foo'); | ||
yield app.actions.asyncChangeOptionalFoo(); | ||
expect(app.state.foo).toBe('async-default-foo'); | ||
const newFoo = 'new-foo'; | ||
app.actions.changeOptionalFoo(newFoo); | ||
expect(app.state.foo).toBe(newFoo); | ||
const newAsyncFoo = 'new-async-foo'; | ||
yield app.actions.asyncChangeOptionalFoo(newAsyncFoo); | ||
expect(app.state.foo).toBe(newAsyncFoo); | ||
})); | ||
}); | ||
//# sourceMappingURL=index.test.js.map |
@@ -136,3 +136,3 @@ import { IFlushCallback, IMutation, IMutationTree, ITrackStateTree } from 'proxy-state-tree'; | ||
}; | ||
export declare type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? { | ||
export declare type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? { | ||
[K in keyof T]: ResolveAction<T[K]>; | ||
@@ -139,0 +139,0 @@ } : never; |
@@ -52,2 +52,19 @@ "use strict"; | ||
}; | ||
const changeOptionalFoo = (context, newFoo) => { | ||
if (newFoo !== undefined) { | ||
context.state.foo = newFoo; | ||
} | ||
else { | ||
context.state.foo = 'default-foo'; | ||
} | ||
}; | ||
const asyncChangeOptionalFoo = (context, newFoo) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield Promise.resolve(); | ||
if (newFoo !== undefined) { | ||
context.state.foo = newFoo; | ||
} | ||
else { | ||
context.state.foo = 'async-default-foo'; | ||
} | ||
}); | ||
const changeFormValue = (_, payload) => { | ||
@@ -70,2 +87,4 @@ const { form, key, value } = payload; | ||
rehydrateAction, | ||
changeOptionalFoo, | ||
asyncChangeOptionalFoo | ||
}; | ||
@@ -396,3 +415,16 @@ const effects = { | ||
}); | ||
test('should allow actions with optional parameter', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
const app = createDefaultOvermind(); | ||
app.actions.changeOptionalFoo(); | ||
expect(app.state.foo).toBe('default-foo'); | ||
yield app.actions.asyncChangeOptionalFoo(); | ||
expect(app.state.foo).toBe('async-default-foo'); | ||
const newFoo = 'new-foo'; | ||
app.actions.changeOptionalFoo(newFoo); | ||
expect(app.state.foo).toBe(newFoo); | ||
const newAsyncFoo = 'new-async-foo'; | ||
yield app.actions.asyncChangeOptionalFoo(newAsyncFoo); | ||
expect(app.state.foo).toBe(newAsyncFoo); | ||
})); | ||
}); | ||
//# sourceMappingURL=index.test.js.map |
@@ -136,3 +136,3 @@ import { IFlushCallback, IMutation, IMutationTree, ITrackStateTree } from 'proxy-state-tree'; | ||
}; | ||
export declare type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? { | ||
export declare type ResolveAction<T> = T extends IOperator<void, infer R> ? () => Promise<R> : T extends IOperator<infer P | undefined, infer R> ? (payload?: P) => Promise<R> : T extends IOperator<infer P, infer R> ? (payload: P) => Promise<R> : T extends IAction<void, infer R> ? () => R : T extends IAction<infer P | undefined, infer R> ? (payload?: P) => R : T extends IAction<infer P, infer R> ? (payload: P) => R : T extends NestedActions ? { | ||
[K in keyof T]: ResolveAction<T[K]>; | ||
@@ -139,0 +139,0 @@ } : never; |
{ | ||
"name": "overmind", | ||
"version": "28.0.0-1614522025331", | ||
"version": "28.0.0-1614633297417", | ||
"description": "Frictionless state management", | ||
@@ -38,6 +38,6 @@ "author": "Christian Alfoni <christianalfoni@gmail.com>", | ||
"is-plain-obj": "^1.1.0", | ||
"betsy": "1.0.2-1614522025331", | ||
"non-blocking-json": "1.1.1-1614522025331", | ||
"betsy": "1.0.2-1614633297417", | ||
"non-blocking-json": "1.1.1-1614633297417", | ||
"tslib": "^1.10.0", | ||
"proxy-state-tree": "6.3.0-1614522025331" | ||
"proxy-state-tree": "6.3.0-1614633297417" | ||
}, | ||
@@ -44,0 +44,0 @@ "devDependencies": { |
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
904925
8937
+ Addedbetsy@1.0.2-1614633297417(transitive)
+ Addednon-blocking-json@1.1.1-1614633297417(transitive)
+ Addedproxy-state-tree@6.3.0-1614633297417(transitive)
- Removedbetsy@1.0.2-1614522025331(transitive)
- Removednon-blocking-json@1.1.1-1614522025331(transitive)
- Removedproxy-state-tree@6.3.0-1614522025331(transitive)
Updatedbetsy@1.0.2-1614633297417