Skip to content

Commit 187336b

Browse files
committed
feat: added support for immer
1 parent ed82551 commit 187336b

9 files changed

Lines changed: 1427 additions & 3905 deletions

File tree

dist/index.d.mts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import { Draft } from 'immer';
2+
13
declare function ripplePrimitive<T>(initial: T): RippleInterface<T>;
24

5+
interface RippleWithImmerUpdate<T> extends RippleInterface<T> {
6+
update(recipe: (draft: Draft<T>) => void | Promise<void>): Promise<void>;
7+
}
38
interface RippleInterface<T> {
49
value: T;
510
subscribe: (cb: () => void, selector?: (v: T) => unknown) => () => void;
@@ -10,6 +15,7 @@ interface RippleFunctionInterface {
1015
<T>(initial: T): RippleInterface<T>;
1116
proxy: <T extends object>(initial: T) => RippleInterface<T>;
1217
primitive: typeof ripplePrimitive;
18+
immer: <T extends object>(initial: T) => RippleWithImmerUpdate<T>;
1319
}
1420

1521
type HandlerType = (payload?: any, tools?: {

dist/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import { Draft } from 'immer';
2+
13
declare function ripplePrimitive<T>(initial: T): RippleInterface<T>;
24

5+
interface RippleWithImmerUpdate<T> extends RippleInterface<T> {
6+
update(recipe: (draft: Draft<T>) => void | Promise<void>): Promise<void>;
7+
}
38
interface RippleInterface<T> {
49
value: T;
510
subscribe: (cb: () => void, selector?: (v: T) => unknown) => () => void;
@@ -10,6 +15,7 @@ interface RippleFunctionInterface {
1015
<T>(initial: T): RippleInterface<T>;
1116
proxy: <T extends object>(initial: T) => RippleInterface<T>;
1217
primitive: typeof ripplePrimitive;
18+
immer: <T extends object>(initial: T) => RippleWithImmerUpdate<T>;
1319
}
1420

1521
type HandlerType = (payload?: any, tools?: {

dist/index.js

Lines changed: 695 additions & 918 deletions
Large diffs are not rendered by default.

dist/index.mjs

Lines changed: 695 additions & 918 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)