Skip to content

Slices inside slices #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lkuoch opened this issue Jan 22, 2019 · 1 comment
Closed

Slices inside slices #89

lkuoch opened this issue Jan 22, 2019 · 1 comment

Comments

@lkuoch
Copy link

lkuoch commented Jan 22, 2019

Hi all,

I'm not sure if this has been asked before but would it be possible to have createSlice reference other maybe an array/collection of other slices.

I'm quite new to redux and have only ready the API docs but it seems to me that slices are a great way to condense all the redux boilerplate and provide a much better way of organising your code.

I was thinking something like this:

  • You only need to create a root slice which can reference every other slice
const rootSlice= createSlice({
    references: [slice1, slice2] // Maybe this or something similar
})
  • Then you effectively have name spaces and only need to create one file with all your actions/reducers etc
// slice1.js
const sliceOne = createSlice({
    // initialState, reducers etc. 
    references: [slice1a] // Refers to another slice
})

So in the end you can have all your redux logic isolated in their own file.

Let me know what you think,
Thanks

@markerikson
Copy link
Collaborator

That's an interesting idea, and not one I'd really thought about. I just opened up #91 to discuss desired behavior for createSlice - let's move the discussion over there.

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

No branches or pull requests

2 participants