@atolljs/angular
v0.1.14
Published
Angular bindings — observableSignal, sharedValue, taskState
Readme
@atolljs/angular
Angular bindings for @atolljs/core — shared-memory fields and worker tasks as
Signals, plus DI registration for pools/clients. Zoneless-friendly; call the
signal factories in an injection context (field initializer or constructor) so
subscriptions release on destroy.
Install
npm install @atolljs/core @atolljs/angularUsage
// main.ts — register the connectWorker client as a DI provider,
// terminated on app teardown (it re-spawns lazily on the next call)
bootstrapApplication(AppComponent, {
providers: [
provideZonelessChangeDetection(),
provideAtoll({ pools: [{ name: 'counter', client: counter }] }),
],
});// app.component.ts
import { Component, effect } from '@angular/core';
import { injectAtollPool, sharedValue, taskState } from '@atolljs/angular';
import { counterMemory } from './counter.memory';
import { counter } from './counter';
@Component({
selector: 'app-root',
template: `<button (click)="increment.run(1)">
count: {{ count() ?? '…' }}</button>`,
})
export class AppComponent {
private readonly counter = injectAtollPool<typeof counter>('counter');
count = sharedValue(counterMemory, 'count');
increment = taskState(this.counter.increment);
constructor() {
effect(() => console.log('count →', this.count()));
}
}API
provideAtoll({ pools }, ...features)— register worker pools orconnectWorkerclients ({ name, client }) as environment providers; usable at app or route level.injectAtollPool(name)— inject a registered pool inside an injection context; mockable viaTestBed.AtollModule.forRoot / forRootAsync / registerPool / registerPoolAsync— NgModule alternative with the same pool tokens + lifecycle.@InjectAtollPool(name)— constructor-parameter decorator form for@Injectable()classes.observableSignal(source)— subscribe to anyObservableValuesnapshot as aSignal.sharedValue(memory, key, select?, options?)— bind one shared-memory field to aSignal; optional selector +equals.taskState(task | asyncFn)— bind anAsyncTask(or any async fn) to{ state: Signal<TaskSnapshot> }plusrun/runOncetriggers.
Notes
- Works with
OnPush+ zoneless change detection out of the box. - Worker-hosted Angular trees (islands) live in the companion package
@atolljs/angular-island.
