2

I am developing an Angular shared component (in its own repo, using ng-packagr and angular 5, to be published as an npm package) and I would like to use @ngrx/store because the component is complex enough to justify this. I would like the store to be internal to the component. In particular, this would mean that:

  • integrating apps would not need to know about @ngrx to use my component
  • integrating apps could use a separate @ngrx store from my component.

What kind of dependency relationships (in my component's package.json, such as peerDependencies or dependencies) and initialization code (in my component's main module my-component.module.ts) would my component need to accomplish this?

What kind of dependency relationships (in the integrating application's package.json) and initialization code (in the integrating application's main module app.module.ts) would the integrating application need to bring in, initialize, and use the component once it is published?

Lyn Headley
  • 11,368
  • 3
  • 33
  • 35
  • A BehaviorSubject could save a small state for a component, why would you use ngrx/store for a component state ? Is it that big ? – ibenjelloun May 18 '18 at 21:06

1 Answers1

0

I think the option that would be best in this case is the new @ngrx/component-store package. I have used this in a project at work and highly recommend it for anything where you would otherwise use a slew of BehaviorSubjects to maintain the state within a component or its children

Ben Rinehart
  • 124
  • 1
  • 4