Skip to content

Commit 360ccb8

Browse files
revert(overmind): remove when as it might lead to bad patterns
1 parent b208a14 commit 360ccb8

File tree

4 files changed

+0
-26
lines changed

4 files changed

+0
-26
lines changed

packages/node_modules/overmind/src/index.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ function createDefaultOvermind() {
2929
await Promise.resolve()
3030
context.state.foo = 'bar2'
3131
}
32-
const whenFooChanges: Action<void, Promise<void>> = async (context) => {
33-
await context.when(() => context.state.foo === 'bar2')
34-
}
3532
const changeValue: Action<{ isAwesome: boolean }> = (_, value) => {
3633
value.isAwesome = !value.isAwesome
3734
}
@@ -50,7 +47,6 @@ function createDefaultOvermind() {
5047
changeFooWithEffect,
5148
changeValue,
5249
waitAndChangeFoo,
53-
whenFooChanges
5450
}
5551
const effects = {
5652
hello() {
@@ -361,15 +357,6 @@ describe('Overmind', () => {
361357
).not.toThrow()
362358
expect(app.state.item.isAwesome).toBe(false)
363359
})
364-
test('should allow waiting for mutation', async () => {
365-
expect.assertions(1)
366-
const app = createDefaultOvermind()
367-
await Promise.all([
368-
app.actions.whenFooChanges(),
369-
app.actions.changeFoo()
370-
])
371-
expect(app.state.foo).toBe('bar2')
372-
})
373360
})
374361

375362
describe('Overmind mock', () => {

packages/node_modules/overmind/src/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,6 @@ export class Overmind<ThisConfig extends IConfiguration>
478478
execution,
479479
proxyStateTree: this.proxyStateTree,
480480
effects: this.trackEffects(this.effects, execution),
481-
when: (cb: () => boolean) => {
482-
return new Promise((resolve) => {
483-
const dispose = this.addFlushListener(() => {
484-
if (cb()) {
485-
dispose()
486-
resolve()
487-
}
488-
})
489-
})
490-
},
491481
revertable: (cb: () => void) => {
492482
const mutations: IMutation[] = []
493483
const dispose = this.addMutationListener((mutation) => {

packages/node_modules/overmind/src/operator.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export function createOperator<ThisConfig extends IConfiguration>(
174174
actions: context.actions,
175175
execution: context.execution,
176176
revertable: context.revertable,
177-
when: context.when
178177
},
179178
context.value,
180179
(err, value, options = {}) => {
@@ -277,7 +276,6 @@ export function createMutationOperator<ThisConfig extends IConfiguration>(
277276
actions: context.actions,
278277
execution: context.execution,
279278
revertable: context.revertable,
280-
when: context.when
281279
},
282280
process.env.NODE_ENV === 'production'
283281
? context.value

packages/node_modules/overmind/src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ export type IContext<ThisConfig extends IConfiguration> = {
3737
state: ResolveState<ThisConfig['state']>
3838
actions: ResolveActions<ThisConfig['actions']>
3939
effects: ThisConfig['effects']
40-
when: (cb: () => boolean) => Promise<void>
4140
revertable: (mutationsCallback: () => any) => () => void
4241
}
4342

0 commit comments

Comments
 (0)