Skip to content

Commit

Permalink
fix(combineEvents): allow usage in sample directly
Browse files Browse the repository at this point in the history
  • Loading branch information
kireevmp committed Mar 17, 2023
1 parent 8e8b08b commit a398e10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/combine-events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
createStore,
Effect,
Event,
EventAsReturnType,
guard,
is,
merge,
Expand Down Expand Up @@ -36,7 +37,7 @@ type ReturnTarget<Result, Target> = Target extends Store<infer S>
export function combineEvents<P extends Shape>(config: {
events: Events<P>;
reset?: Unit<any>;
}): Event<P>;
}): EventAsReturnType<P>;

export function combineEvents<
P extends Shape,
Expand Down
17 changes: 17 additions & 0 deletions test-typings/combine-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
createEvent,
createStore,
createEffect,
sample,
} from 'effector';
import { combineEvents } from '../src/combine-events';

Expand Down Expand Up @@ -260,3 +261,19 @@ import { combineEvents } from '../src/combine-events';

expectType<Effect<Target, void>>(effect);
}

// Can be used in sample
{
const foo = createEvent<number>();
const bar = createEvent<string>();

sample({
clock: combineEvents({
events: [foo, bar],
}),
fn: ([a, b]) => {
expectType<number>(a);
expectType<string>(b);
},
});
}

0 comments on commit a398e10

Please sign in to comment.