Skip to content

Commit

Permalink
fix(wire): add Fns generic to createWire
Browse files Browse the repository at this point in the history
  • Loading branch information
smmoosavi committed Jun 18, 2020
1 parent 3640457 commit 7a23e2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ declare type CB<T> = (t: T) => void;

declare type CovarianceGuard<T> = [T, unknown];

export declare function createWire<V>(initialValue: V): Wire<V>;
export declare function createWire<V, Fns = {}>(initialValue: V): Wire<V, Fns>;

declare type Defined<T> = T extends undefined ? never : T;

Expand Down
6 changes: 3 additions & 3 deletions src/wire/create-wire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { createFnsWire } from '../fn-wire/create-fns-wire';
import { createStateWire } from '../state-wire/create-state-wire';
import { Wire } from './wire';

export function createWire<V>(initialValue: V): Wire<V> {
const [stateWire] = createStateWire({}, initialValue);
const [fnsWire] = createFnsWire({});
export function createWire<V, Fns = {}>(initialValue: V): Wire<V, Fns> {
const [stateWire] = createStateWire<V>({}, initialValue);
const [fnsWire] = createFnsWire<Fns>({});
return { ...fnsWire, ...stateWire };
}

0 comments on commit 7a23e2b

Please sign in to comment.