This library contains the data access layer for the activity feature.
-
Import the Module. Import the
SharedActivityDataAccessModule
into your application's module or wherever you want to use it.import { SharedActivityDataAccessModule } from '@plastik/shared/activity/data-access'; @NgModule({ imports: [SharedActivityDataAccessModule], }) export class AppModule {}
-
Dispatch Actions: Use the activityActions to dispatch actions to the store.
import { inject } from '@angular/core'; import { Store } from '@ngrx/store'; import { activityActions } from '@plastik/shared/activity/data-access'; export class MyComponent implements OnInit { readonly #store = inject(Store); ngOnInit(): void { this.#store.dispatch(activityActions.setActivity({ isActive: false })); } }
-
Select State: Use the selectors to get the state from the store.
import { inject } from '@angular/core'; import { Store } from '@ngrx/store'; import { selectIsActive } from '@plastik/shared/activity/data-access'; export class MyOtherComponent { readonly #store = inject(Store); isActive$ = this.#store.select(selectIsActive); }
Run nx test shared-activity-data-access
to execute the unit tests.