I am wrapping the create function of zustand, but I have a problem, I can not get the methods prompt through get() when using, does anyone know how to deal with it?
function create<T, M>(
state: T,
methods: (set: (s: T) => void, get: () => T & M) => M
): T & M {
const m = methods(
(_state) => void 0,
() => ({ ...state, ...m })
);
return {
...state,
...m,
}
}
const store = create({ a: 1, count: 10 }, (set, get) => ({
test() {
get() // Expected: prompt the test, test2 methods
},
test2() {
}
}));
Expected: prompt the test, test2 methods
Actual: only have state prompts