Skip to content

Commit

Permalink
chore: release v0.1.0 (#274)
Browse files Browse the repository at this point in the history
# Release
- Update changelog
- Bump major prerelease version

# Build
- Require RxJS ^7.2.0 peer dependency
- Add global UMD ID to prevent dash usage
- Add external UMD module ID for `@ngrx/component-store`
- Decorate `Router` and `ActivatedRoute` dependencies with `Inject` to
remove build warnings about unused imports
  • Loading branch information
LayZeeDK authored Oct 20, 2022
1 parent a6f664c commit 5366227
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 13 deletions.
127 changes: 124 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,133 @@
# Changelog
# Router Component Store changelog

## 0.0.2
## 0.1.0 (2022-10-20)

## Features

- Add `RouterStore`
- Remove `LocalRouterStore`
- Add `provideLocalRouterStore`
- Remove `GlobalRouterStore`
- Add `provideGlobalRouterStore`

## Bug fixes

- Fix [#272](https://github.com/ngworker/router-component-store/issues/272): Class constructor ComponentStore cannot be invoked without 'new'

## **BREAKING CHANGES**

### Require RxJS 7.2

We now require at least RxJS version 7.2 to import operators from the primary entry point of the `rxjs` package.

### LocalRouterStore is removed

`LocalRouterStore` is replaced by `RouterStore` and `provideLocalRouterStore`.

#### Migration

Use `provideLocalRouterStore()` as component-level provider and inject `RouterStore` instead of `LocalRouterStore`.

Before:

```typescript
// hero-detail.component.ts
// (...)
import { LocalRouterStore } from '@ngworker/router-component-store';

@Component({
// (...)
providers: [LocalRouterStore],
})
export class HeroDetailComponent {
heroId$: Observable<string> = this.routerStore.selectQueryParam('id');

constructor(private routerStore: LocalRouterStore) {}
}
```

After:

```typescript
// hero-detail.component.ts
// (...)
import {
provideLocalRouterStore,
RouterStore,
} from '@ngworker/router-component-store';

@Component({
// (...)
providers: [provideLocalRouterStore()],
})
export class HeroDetailComponent {
heroId$: Observable<string> = this.routerStore.selectQueryParam('id');

constructor(private routerStore: RouterStore) {}
}
```

### GlobalRouterStore is removed

`GlobalRouterStore` is replaced by `RouterStore` and `provideGlobalRouterStore`.

#### Migration

Add `provideGlobalRouterStore()` to your root environment injector and inject `RouterStore` instead of `GlobalRouterStore`.

Before:

```typescript
// hero.service.ts
// (...)
import { GlobalRouterStore } from '@ngworker/router-component-store';

@Injectable({
providedIn: 'root',
})
export class HeroService {
activeHeroId$: Observable<string> = this.routerStore.selectQueryParam('id');

constructor(private routerStore: GlobalRouterStore) {}
}
```

After:

```typescript
// app.module.ts
// (...)
import { provideGlobalRouterStore } from '@ngworker/router-component-store';

@NgModule({
// (...)
providers: [provideGlobalRouterStore()],
})
export class AppModule {}
```

```typescript
// hero.service.ts
// (...)
import { RouterStore } from '@ngworker/router-component-store';

@Injectable({
providedIn: 'root',
})
export class HeroService {
activeHeroId$: Observable<string> = this.routerStore.selectQueryParam('id');

constructor(private routerStore: RouterStore) {}
}
```

## 0.0.2 (2021-11-20)

### Refactorings

- Encapsulate members inherited from `ComponentStore`

## 0.0.1
## 0.0.1 (2021-11-20)

### Features

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# @ngworker/router-component-store
# Router Component Store

Angular Router-connecting NgRx component stores.
[`@ngworker/router-component-store`](https://www.npmjs.com/package/@ngworker/router-component-store)

An Angular Router-connecting NgRx component store.

## Compatibility

Expand Down
6 changes: 5 additions & 1 deletion packages/router-component-store/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/packages/router-component-store",
"lib": {
"entryFile": "src/index.ts"
"entryFile": "src/index.ts",
"umdId": "ngworker.routerComponentStore",
"umdModuleIds": {
"@ngrx/component-store": "ngrx.componentStore"
}
}
}
4 changes: 2 additions & 2 deletions packages/router-component-store/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@ngworker/router-component-store",
"version": "0.0.2",
"version": "0.1.0",
"description": "Angular Router-connecting NgRx component stores.",
"license": "MIT",
"peerDependencies": {
"@angular/core": "^12.2.0",
"@angular/router": "^12.2.0",
"@ngrx/component-store": "^12.0.0",
"rxjs": "^7.0.0"
"rxjs": "^7.2.0"
},
"dependencies": {
"tslib": "^2.3.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { Data, Params, Router } from '@angular/router';
import { ComponentStore } from '@ngrx/component-store';
import { map, Observable } from 'rxjs';
Expand Down Expand Up @@ -55,7 +55,10 @@ export class GlobalRouterStore
(routerState) => routerState.url
);

constructor(router: Router, serializer: MinimalRouterStateSerializer) {
constructor(
@Inject(Router) router: Router,
serializer: MinimalRouterStateSerializer
) {
super({
routerState: serializer.serialize(router.routerState.snapshot),
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { ActivatedRoute, Data, Params, Router } from '@angular/router';
import { ComponentStore } from '@ngrx/component-store';
import { map, Observable } from 'rxjs';
Expand Down Expand Up @@ -46,8 +46,8 @@ export class LocalRouterStore
);

constructor(
route: ActivatedRoute,
router: Router,
@Inject(ActivatedRoute) route: ActivatedRoute,
@Inject(Router) router: Router,
serializer: MinimalRouterStateSerializer
) {
super({
Expand Down

0 comments on commit 5366227

Please sign in to comment.