18.2.1 • Published 12 months ago
@ng-atomic/core v18.2.1
@ng-atomic/core
@ng-atomic/core
is a library that enables dependency injection for components.
Install
$ npm i @ng-atomic/core
Usage
import { Component, Directive, inject, input } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { Effect, TokenizedType, provideComponent, InjectableComponent } from '@ng-atomic/core';
import { NgAtomicComponent } from '@ng-atomic/core';
import 'zone.js';
export enum ActionId {
CREATE = 'Create',
}
@TokenizedType()
@Directive({ standalone: true, selector: 'example' })
export class ExampleComponentStore extends InjectableComponent {
static readonly ActionId = ActionId;
readonly name = input<string>('');
}
@Component({
standalone: true,
selector: `example`,
template: `
<div>{{ store.name() }}</div>
<button (click)="onClick()">ADD</button>
`,
hostDirectives: [
{
directive: ExampleComponentStore,
inputs: ['name'],
},
],
})
export class ExampleComponent extends NgAtomicComponent {
protected readonly store = inject(ExampleComponentStore);
protected onClick() {
this.dispatch({ id: ActionId.CREATE, payload: 'ADD' });
}
}
@Component({
selector: 'app-root',
standalone: true,
imports: [ExampleComponentStore],
template: `
<example [name]="'test'" (action)="dispatch($event)" injectable/>
`,
providers: [provideComponent(ExampleComponentStore, () => ExampleComponent)],
})
export class App extends NgAtomicComponent {
@Effect(ExampleComponentStore.ActionId.CREATE)
protected create() {
alert('created!!');
}
}
bootstrapApplication(App);
LISENCE
MIT
17.13.0
1 year ago
18.2.1
12 months ago
17.14.0
12 months ago
18.2.0
12 months ago
18.1.0
12 months ago
18.0.0
12 months ago
17.10.0
1 year ago
17.11.0
1 year ago
17.12.0
1 year ago
17.14.0-preview-19-fix-deps.1
12 months ago
17.14.0-preview-update-nx-workspace-19.2
12 months ago
17.14.0-preview-update-nx-workspace-19.3
12 months ago
17.3.0
1 year ago
17.0.3
1 year ago
17.2.0
1 year ago
17.0.2
1 year ago
17.5.0
1 year ago
17.3.2
1 year ago
17.4.0
1 year ago
17.3.1
1 year ago
17.0.4
1 year ago
17.1.0
1 year ago
17.0.1
1 year ago
17.0.0
1 year ago
17.7.0
1 year ago
17.6.1
1 year ago
17.3.4
1 year ago
17.6.0
1 year ago
17.3.3
1 year ago
17.9.0
1 year ago
17.8.0
1 year ago
17.7.1
1 year ago
17.3.5
1 year ago
16.3.1
1 year ago
16.2.0
2 years ago
16.1.1
2 years ago
16.1.0
2 years ago
16.0.0
2 years ago
15.1.1
2 years ago
0.0.1
2 years ago