@atolljs/angular 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -7
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,11 +1,80 @@
|
|
|
1
1
|
# @atolljs/angular
|
|
2
2
|
|
|
3
|
-
Angular bindings for `@atolljs/core` —
|
|
4
|
-
Signal
|
|
5
|
-
|
|
3
|
+
Angular bindings for `@atolljs/core` — shared-memory fields and worker tasks as
|
|
4
|
+
`Signal`s, plus DI registration for pools/clients. Zoneless-friendly; call the
|
|
5
|
+
signal factories in an injection context (field initializer or constructor) so
|
|
6
|
+
subscriptions release on destroy.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- `sharedValue(memory, key)` — a shared-memory field as a `Signal`.
|
|
9
|
-
- `taskState(task)` — `{ state }` Signal of the task snapshot plus `run`/`runOnce`.
|
|
8
|
+
**[Atoll — package documentation](https://jwhenry3.github.io/atolljs/consumer/quickstart/)**
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @atolljs/core @atolljs/angular
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
// main.ts — register the connectWorker client as a DI provider,
|
|
20
|
+
// terminated on app teardown (it re-spawns lazily on the next call)
|
|
21
|
+
bootstrapApplication(AppComponent, {
|
|
22
|
+
providers: [
|
|
23
|
+
provideZonelessChangeDetection(),
|
|
24
|
+
provideAtoll({ pools: [{ name: 'counter', client: counter }] }),
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
// app.component.ts
|
|
31
|
+
import { Component, effect } from '@angular/core';
|
|
32
|
+
import { injectAtollPool, sharedValue, taskState } from '@atolljs/angular';
|
|
33
|
+
import { counterMemory } from './counter.memory';
|
|
34
|
+
import { counter } from './counter';
|
|
35
|
+
|
|
36
|
+
@Component({
|
|
37
|
+
selector: 'app-root',
|
|
38
|
+
template: `<button (click)="increment.run(1)">
|
|
39
|
+
count: {{ count() ?? '…' }}</button>`,
|
|
40
|
+
})
|
|
41
|
+
export class AppComponent {
|
|
42
|
+
private readonly counter = injectAtollPool<typeof counter>('counter');
|
|
43
|
+
count = sharedValue(counterMemory, 'count');
|
|
44
|
+
increment = taskState(this.counter.increment);
|
|
45
|
+
|
|
46
|
+
constructor() {
|
|
47
|
+
effect(() => console.log('count →', this.count()));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API
|
|
53
|
+
|
|
54
|
+
- `provideAtoll({ pools }, ...features)` — register worker pools or
|
|
55
|
+
`connectWorker` clients (`{ name, client }`) as environment providers;
|
|
56
|
+
usable at app or route level.
|
|
57
|
+
- `injectAtollPool(name)` — inject a registered pool inside an injection
|
|
58
|
+
context; mockable via `TestBed`.
|
|
59
|
+
- `AtollModule.forRoot / forRootAsync / registerPool / registerPoolAsync` —
|
|
60
|
+
NgModule alternative with the same pool tokens + lifecycle.
|
|
61
|
+
- `@InjectAtollPool(name)` — constructor-parameter decorator form for
|
|
62
|
+
`@Injectable()` classes.
|
|
63
|
+
- `observableSignal(source)` — subscribe to any `ObservableValue` snapshot as
|
|
64
|
+
a `Signal`.
|
|
65
|
+
- `sharedValue(memory, key, select?, options?)` — bind one shared-memory field
|
|
66
|
+
to a `Signal`; optional selector + `equals`.
|
|
67
|
+
- `taskState(task | asyncFn)` — bind an `AsyncTask` (or any async fn) to
|
|
68
|
+
`{ state: Signal<TaskSnapshot> }` plus `run`/`runOnce` triggers.
|
|
69
|
+
|
|
70
|
+
## Notes
|
|
71
|
+
|
|
72
|
+
- Works with `OnPush` + zoneless change detection out of the box.
|
|
73
|
+
- Worker-hosted Angular trees (islands) live in the companion package
|
|
74
|
+
[`@atolljs/angular-island`](../angular-island).
|
|
75
|
+
|
|
76
|
+
## Documentation
|
|
77
|
+
|
|
78
|
+
- [Atoll — package documentation](https://jwhenry3.github.io/atolljs/consumer/quickstart/)
|
|
79
|
+
- [Angular guide](https://jwhenry3.github.io/atolljs/consumer/fw-angular/)
|
|
80
|
+
- [Worker islands for Angular](https://jwhenry3.github.io/atolljs/consumer/fw-angular/worker-islands/)
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atolljs/angular",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Angular bindings — observableSignal, sharedValue, taskState",
|
|
5
|
+
"homepage": "https://jwhenry3.github.io/atolljs/consumer/quickstart/",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"exports": {
|
|
7
8
|
".": "./src/index.ts"
|
|
@@ -10,15 +11,19 @@
|
|
|
10
11
|
"src"
|
|
11
12
|
],
|
|
12
13
|
"publishConfig": {
|
|
13
|
-
"access": "public"
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org"
|
|
14
16
|
},
|
|
15
17
|
"peerDependencies": {
|
|
16
|
-
"@atolljs/core": "0.1.
|
|
18
|
+
"@atolljs/core": "0.1.2",
|
|
17
19
|
"@angular/core": "^22.2.0"
|
|
18
20
|
},
|
|
19
21
|
"repository": {
|
|
20
22
|
"type": "git",
|
|
21
23
|
"url": "https://github.com/jwhenry3/atolljs",
|
|
22
24
|
"directory": "packages/angular"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/jwhenry3/atolljs/issues"
|
|
23
28
|
}
|
|
24
29
|
}
|