You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ multiple model support and immutable data exposed as RxJS Observable.
12
12
-[Code of Conduct](https://github.com/angular-extensions/model/blob/master/CODE_OF_CONDUCT.md)
-[Blog](https://medium.com/@tomastrajan/model-pattern-for-angular-state-management-6cb4f0bfed87) about introduction to Angular Model Pattern
15
+
-[Blog](https://medium.com/@tomastrajan/model-pattern-for-angular-state-management-6cb4f0bfed87) about introduction to Angular Model Pattern
16
16
-[Advanced Usage Patterns](https://tomastrajan.github.io/angular-model-pattern-example#/advanced) with more how-tos and examples
17
17
18
18
## Documentation
@@ -174,12 +174,26 @@ implementation to your project manually.
174
174
One of the changes compared to `ngx-model` is that the `@angular-extensions/model` uses new
175
175
`providedIn: 'root'` syntax (since Angular 6) so that we don't need to import `NgxModelModule`
176
176
or anything similar to register `ModelFactory` into Angular dependency injection (DI) context.
177
-
All we have to do is to import `ModelFactory` in the constructor of at least one service in our
177
+
All we have to do is to import `ModelFactory` in the constructor of at least one service in our
178
178
application like this `constructor(private modelFactory: ModelFactory<SomeType[]>) {}` and we're
179
179
good to go. This new feature is called tree-shakeable providers:
180
180
181
181
> There is now a new, recommended, way to register a provider, directly inside the @Injectable() decorator, using the new providedIn attribute. It accepts 'root' as a value or any module of your application. When you use 'root', your injectable will be registered as a singleton in the application, and you don’t need to add it to the providers of the root module. Similarly, if you use providedIn: UsersModule, the injectable is registered as a provider of the UsersModule without adding it to the providers of the module ([source](https://blog.ninja-squad.com/2018/05/04/what-is-new-angular-6/))
182
182
183
+
#### Migration from `ngx-model`
184
+
185
+
Migration should be rather simple, please follow these steps:
186
+
187
+
1. remove dependency to `ngx-model`
188
+
2. install `npm i -S @angular-extensions/model`
189
+
3. remove `NgxModelModule` from imports of your `@NgModule` in `App` or `Core` module based on where you added it
190
+
4. search and replace imports from `ngx-model` and replace them with `@angular-extensions/model`
191
+
5. this should be it! The API didn't change so this should be all that it takes to migrate to the new package
192
+
6. (optional) refactor your existing model services to use `@Injectable({ providedIn: 'root' })` (or other module instead of `root`)
193
+
instead of `@Injectable()` and remove them from `@NgModule({ providers: [MyModelService] })` of your modules
194
+
195
+
The 6th step depends on your preferences, it is still possible to use new `@angular-extensions/model` with classic
196
+
providers, just use `--module <relative-path-to-module>` flag when generating new model services using schematics
0 commit comments