Skip to content

Enhance Template Usage#1

Open
pjcast wants to merge 4 commits into
jaywick:mainfrom
pjcast:fix-reducer
Open

Enhance Template Usage#1
pjcast wants to merge 4 commits into
jaywick:mainfrom
pjcast:fix-reducer

Conversation

@pjcast

@pjcast pjcast commented Aug 24, 2023

Copy link
Copy Markdown

Hi,

I've briefly tested the changes, feel free to incorporate them. Some issues I encountered using your fork were:

  • Couldn't use a custom reducer method
    • Had to update reducer template definition
  • Dispatch to custom reducer actions wasn't possible
    • Updated template logic (borrowed from React)
  • useStore forced to return whole type
    • Created an alternate method 'pickStore'. Uses Pick template. There are two ways one could use this in code:
const { user } = pickStore((store: StoreItems) => { return { 
    user: store.user,
    something: store.something
}});

Or:

const { user, something } = pickStore<'user'|'something'>();

I don't like using strings... but, it is using keyof, so, the strings have to be actual property methods... so, refactoring store item names would cause an error in either case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant