-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from JuliusKoronci/feat/refactor-store-names
Feat/refactor store names
- Loading branch information
Showing
9 changed files
with
105 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export * from './store'; | ||
export * from './classic-store'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Button, Flex, Text } from '@radix-ui/themes'; | ||
import React from 'react'; | ||
import useStore, { useCounterPromiseSelector } from './counterStorePromise'; | ||
|
||
export const DefaultPromise = () => { | ||
const [, updateCount] = useStore(); | ||
const count = useCounterPromiseSelector((state) => state.count); | ||
const increment = () => | ||
updateCount((prevState) => ({ ...prevState, count: prevState.count + 1 })); | ||
return ( | ||
<Flex direction="column" gap="2"> | ||
<Text>We are counting hydrating default: {count}</Text> | ||
<Button onClick={increment}>Let's go, promise counter</Button> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { buildClassicStore } from '../../lib'; | ||
|
||
export interface CounterState { | ||
count: number; | ||
} | ||
|
||
const counterStore3Builder = await buildClassicStore<CounterState>({ | ||
hydrator: () => Promise.resolve({ count: 88 }), | ||
beforeLoadState: { count: 0 }, | ||
}); | ||
const { useStore, useSelector: useCounterPromiseSelector } = | ||
counterStore3Builder; | ||
|
||
export { useCounterPromiseSelector }; | ||
export default useStore; |