diff --git a/.npmignore b/.npmignore index 24c5f79..b0f5ec0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,6 +1,9 @@ -build.js .vscode -/staterino.js yarn.lock .prettierrc -.eslintrc.js \ No newline at end of file +.eslintrc.js + +/build.js +/staterino.js +/staterino.test.js +/type-test.js \ No newline at end of file diff --git a/type-test.ts b/type-test.ts new file mode 100644 index 0000000..6b6d3d3 --- /dev/null +++ b/type-test.ts @@ -0,0 +1,40 @@ +import staterino from 'staterino' + +interface State { + book: boolean + house: number + nested: { + hi: number + } +} + +const initialState: State = { + book: true, + house: 10, + nested: { + hi: 3 + } +} + +const useStore = staterino({ + state: initialState, + hooks: { useLayoutEffect: true, useReducer: true }, + merge: () => null +}) + +const val = useStore(s => s.house) + +const [blah, house, hi] = useStore(['hi', s => s.house, s => s.nested.hi]) + +useStore.subscribe( + s => s.book, + book => console.log(book) +) + +useStore.subscribe([s => s.house, s => s.nested.hi], (house, hi) => {}) +useStore.subscribe(s => {}) +useStore.subscribe([s => s.book, 'hello'], (book, h) => {}) + +useStore.set([{ book: true }, { nested: {} }, s => s, [[[{ house: 3 }]]]]) + +const s = useStore()