Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 15 2019 16:45
    johannesjo commented #20
  • Sep 21 2019 04:04
    JimTheMan closed #16
  • May 04 2019 00:15
    felixunivers edited #17
  • Apr 29 2019 21:30
    felixunivers opened #17
  • Apr 10 2019 21:15
    rezord opened #16
  • Jan 31 2019 20:44
    alex-okrushko commented #1511
  • Jan 31 2019 20:21
    brandonroberts edited #1538
  • Jan 31 2019 20:20
    brandonroberts edited #1538
  • Jan 31 2019 20:18
    brandonroberts labeled #1538
  • Jan 31 2019 20:18
    brandonroberts labeled #1538
  • Jan 31 2019 20:18
    brandonroberts opened #1538
  • Jan 31 2019 12:11
    timdeschryver closed #1536
  • Jan 31 2019 12:11
    timdeschryver commented #1536
  • Jan 31 2019 12:08
    timdeschryver closed #1537
  • Jan 31 2019 12:08
    timdeschryver commented #1537
  • Jan 31 2019 11:59
    olefrank commented #1036
  • Jan 31 2019 11:59
    olefrank commented #1036
  • Jan 31 2019 11:39
    jonrimmer commented #103
  • Jan 31 2019 09:42
    j00y opened #1537
  • Jan 31 2019 09:33
    omarperezm edited #1536
Sargo Darya
@SargoDarya
Question is: Is this against all best practices and thus the reason it's not easily doable? Are we thinking wrong? What would be the right way?
Derek
@derekkite
@SargoDarya and the data for each company is spread over multiple store slices?
Sargo Darya
@SargoDarya
We basically have 3 state slices here. Companies/RecipientLists/Counterparties
So, rootReducers has { companies: companyReducer, recipientLists: recipientListReducer, counterparties: counterpartyReducer } and that's fed into StoreModule.forRoot(rootReducers, ...)
Derek
@derekkite
are the recipient lists and counterparties a list of ids of companies? I'm thinking you have selection state in your component, with all the ids of the companies in both recipient and counterparty lists.
Sargo Darya
@SargoDarya
RecipientLists are basically a collection of { id, name, companyIds }, yes and counterparties are also a list of company ids.
Derek
@derekkite
Selecting one or a few companies to insert is an action taking the ids from the component, I imagine. But selectall, they aren't in the component, but in the state slice. I see.
Sargo Darya
@SargoDarya
You got the idea. So I'm really unsure what the best way here would be.
Derek
@derekkite
to get the ids through a selector, then into an action, then into the other slice. too much. Yes, a metareducer would likely be best. I avoid metareducers because they make refactoring more complicated, but this is almost a "copy this whole state, modify it a bit, then insert in another state" situation
Sargo Darya
@SargoDarya
Can you quickly give me an idea on how it would complicate refactoring? Just want to know the potential downsides to that solution.
Derek
@derekkite
say you modify the company data structure. Or break the company data into different slices for some relational type component. Typically you change the reducer and effects and selectors, essentially the data in and data out interfaces, and other consumers of the data aren't affected.
Sargo Darya
@SargoDarya
So with the meta reducer you now have one more potential place which breaks which is unrelated to what you actually change. Got it.
Derek
@derekkite
in this situation you would have one function where the data is taken from one slice and mapped to a different shape for the second slice. One function in one place. Not too bad.
Sargo Darya
@SargoDarya
Guess I have to evaluate if the benefits here overweigh the downsides. Thank you very much for your help Derek, much appreciated!
Christian Francia
@ctfrancia
anyone familiar with OneSignal for push notifications? I have this problem where when the app is started up for the first time, one of the methods for getting the push token is not called but when the app is restarted the method is called, I created post OneSignal/OneSignal-Cordova-SDK#587 to read more about it. any help would be nice
apcs.guide
@ApcsGuide_twitter
I ran ng upgrade @ngrx/store and it said incompatible peer dependency to @angular/core (requires ^8.0.0, would install "9.0.0-rc.7") so does ngrx not work with angular 9?
Derek
@derekkite
@ApcsGuide_twitter works fine
apcs.guide
@ApcsGuide_twitter
in the constructor is there any benefit to injecting multiple stores i.e. menuStore: Store<MenuState>, columnStore: Store<ColumnState> vs just injecting the root level i.e. store: Store<RootState>
Stephen Adams
@Stephenradams
@ApcsGuide_twitter I don't think there is a benefit to injecting multiple stores as opposed to the single RootState. If you later want to add a new state, adding that to the RootState makes it automatically available everywhere. This mean you only update one file if instead of having to go through all your files finding where you want to inject this new State.
Derek
@derekkite
@ApcsGuide_twitter the <state> is for typing. You wouldn't want to inject more than one.
dev-ster
@dev-ster
how do you prepopulate some entities in ngrx entity?
Derek
@derekkite
@dev-ster from where? If you want to initialize the entity with some values https://ngrx.io/guide/entity/adapter#getinitialstate
apcs.guide
@ApcsGuide_twitter
for the components that will be used throughout the application, i have each component in its own module. does it make sense to have the actions/reducers/selectors/effects in that module or should i put them in the core module
Stephen Adams
@Stephenradams
@ApcsGuide_twitter well you could have a shared module. This module can have the component which is being shared throughout the app. Then you can have the reducer, Actions and Effects in that shared module.
apcs.guide
@ApcsGuide_twitter
just wondering, why not put it in the module of the component that uses it
BertrandMarechal
@BertrandMarechal
it's a mater of separation of concern - the dumbest the bits are, the better
apcs.guide
@ApcsGuide_twitter
k, thanks
BertrandMarechal
@BertrandMarechal
I tend to separate my modules/stores to improve testing and avoid data conflicts
apcs.guide
@ApcsGuide_twitter
k
Stephen Adams
@Stephenradams
totally agree with @BertrandMarechal
apcs.guide
@ApcsGuide_twitter
so i started with a module that had a bunch of components. but then i needed to use those components outside of that module so i made them available to use outside the module if you imported that module. i realized that got pretty messy so i took each of those components and made them into their own modules. i.e. src/app/counter, src/app/book, etc... now whenever i need to use those components in a module i import that module (i.e. counter) into the module where i used it. this seemed more clean to me and seem to follow how angular material does it with MatButtonModule etc... what do you think?
BertrandMarechal
@BertrandMarechal
yeah that makes sense - based on that, the data would be just stored in the modules/components importing the sub components ?
as in when you user a time picker, the timepicker is not gonna hold its data in the store
Stephen Adams
@Stephenradams
That's a tricky question. I get the idea to use a module per component, similar to Angular Material. You could use a Smart Component that loads in the Shared Components. These Smart Components are in their own modules, which also have the Reducers, Actions, for that Smart Components functionality. That way you are reusing the common components, but have specific smart components for each section.
BertrandMarechal
@BertrandMarechal
the data might be relevant only for the importer context, and then just passed as input to the "dumb" components
apcs.guide
@ApcsGuide_twitter
so for those module components i ended up putting the store in the core module
but maybe i should of put it in the shared module. i think i didn't put it in the shared because i knew what to do for putting it in the core but not sure about how to go about it for the shared module
BertrandMarechal
@BertrandMarechal
what type of component are we talking about ? an example could be good
apcs.guide
@ApcsGuide_twitter
do you have any example code to point me to for putting it in the shared
i mean for putting the store in the shared ^
sorry, i was talking about the store. i should of specified
BertrandMarechal
@BertrandMarechal
like if you have an application with a user list that you are using in several other components, maybe this user list is relevant to put in a user store ?
a library management app could need a list or users to manage subscriptions, and the same list of users when it comes to borrowing a book
apcs.guide
@ApcsGuide_twitter
yeah, so for that case. If i have a user list then in my design i'd put it in src/app/user-list as a module. so the user list component would be in the user list module. now where should i put the store for that user list. right now i have the store for it in the core module. but should i put it in the shared module. and if i put it in the shared module i have a few questions about how to do that
so right now it'd be: src/app/core/store/user-list/user-list.actions.ts, src/app/core/store/user-list/user-list.effects.ts etc...
Derek
@derekkite
@ApcsGuide_twitter that is what feature reducers are for.
apcs.guide
@ApcsGuide_twitter
@derekkite k. does that mean i'd have it in src/app/user-list/store/user-list.actions.ts and then in the user-list.module.ts i'd do StoreModule.forFeature('user-list', reducers); then if I do that, what if I want to use one of the user-list selectors outside of the user-list module. Inside the user-list.module.ts do I need to export the selectors? Or would I just be able to use them as long as I imported the UserListModule
Derek
@derekkite
@ApcsGuide_twitter in that case the feature reducer would need to be loaded from root or some common root to all the components that would use it. The situation is similar to injectable services. If you want a singleton you need to provide it in the app module or a child of the app module.
apcs.guide
@ApcsGuide_twitter
k, makes sense. thanks
thanks everyone. this cleared up a lot of questions for me