@wirestate/lit-signals 0.6.0 → 0.6.1
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/CHANGELOG.md +11 -0
- package/README.md +59 -0
- package/cjs/development/index.js +0 -8
- package/cjs/development/index.js.map +1 -1
- package/cjs/production/index.js +1 -1
- package/esm/development/index.js +1 -1
- package/esm/production/index.js +1 -1
- package/index.d.ts +11 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## 0.7.0
|
|
2
|
+
|
|
3
|
+
- Add `useScope` in `@wirestate/react`
|
|
4
|
+
- New lit elements modules - `@wirestate/lit` and `@wirestate/lit-signals`
|
|
5
|
+
- `EventBus`: add `unsubscribe` method for explicit handler removal by reference
|
|
6
|
+
- `QueryBus`: add `unregister` method for explicit handler removal by type and reference
|
|
7
|
+
- `CommandBus`: add `unregister` method for explicit handler removal by type and reference
|
|
8
|
+
- `WireScope`: add new event/command/query subscribe-unsubscribe methods
|
|
9
|
+
- Export more alias / methods from `@wirestate/core`
|
|
10
|
+
- Export more alias / methods from `@wirestate/react-mobx`
|
|
11
|
+
|
|
1
12
|
## 0.6.3
|
|
2
13
|
|
|
3
14
|
- Update readme files for each module
|
package/README.md
CHANGED
|
@@ -11,6 +11,65 @@ Re-exports `@lit-labs/signals` for use with wirestate services in Lit elements.
|
|
|
11
11
|
npm install @wirestate/lit-signals @lit-labs/signals
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import {
|
|
18
|
+
signal,
|
|
19
|
+
computed,
|
|
20
|
+
watch,
|
|
21
|
+
Signal,
|
|
22
|
+
State,
|
|
23
|
+
Computed,
|
|
24
|
+
} from '@wirestate/lit-signals';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Example service:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { Injectable, Inject, WireScope } from '@wirestate/core';
|
|
31
|
+
import { signal, computed, State, Computed } from '@wirestate/lit-signals';
|
|
32
|
+
|
|
33
|
+
@Injectable()
|
|
34
|
+
export class CounterService {
|
|
35
|
+
public readonly count: State<number> = signal(0);
|
|
36
|
+
public readonly isEven: Computed<boolean> = computed(() => this.count.get() % 2 === 0);
|
|
37
|
+
|
|
38
|
+
public constructor(@Inject(WireScope) private scope: WireScope) {}
|
|
39
|
+
|
|
40
|
+
public increment(): void {
|
|
41
|
+
this.count.set(this.count.get() + 1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Example Lit element:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { LitElement, html } from 'lit';
|
|
50
|
+
import { customElement } from 'lit/decorators.js';
|
|
51
|
+
import { injection } from '@wirestate/lit';
|
|
52
|
+
import { watch, computed } from '@wirestate/lit-signals';
|
|
53
|
+
|
|
54
|
+
import { CounterService } from './services';
|
|
55
|
+
|
|
56
|
+
@customElement('my-component')
|
|
57
|
+
class MyComponent extends LitElement {
|
|
58
|
+
@injection({ injectionId: CounterService })
|
|
59
|
+
private readonly counterService!: CounterService;
|
|
60
|
+
|
|
61
|
+
private isOddLabel = computed(() => (this.counterService.count.get() % 2 === 0 ? "even" : "odd"));
|
|
62
|
+
|
|
63
|
+
render() {
|
|
64
|
+
return html`
|
|
65
|
+
<button @click="${() => this.counterService.increment()}">
|
|
66
|
+
count: ${watch(this.counterService.count)} (${watch(this.isOddLabel)})
|
|
67
|
+
</button>
|
|
68
|
+
`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
14
73
|
## License
|
|
15
74
|
|
|
16
75
|
MIT
|
package/cjs/development/index.js
CHANGED
|
@@ -4,10 +4,6 @@ var signals = require('@lit-labs/signals');
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports, "Computed", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return signals.Computed; }
|
|
10
|
-
});
|
|
11
7
|
Object.defineProperty(exports, "Signal", {
|
|
12
8
|
enumerable: true,
|
|
13
9
|
get: function () { return signals.Signal; }
|
|
@@ -28,10 +24,6 @@ Object.defineProperty(exports, "signal", {
|
|
|
28
24
|
enumerable: true,
|
|
29
25
|
get: function () { return signals.signal; }
|
|
30
26
|
});
|
|
31
|
-
Object.defineProperty(exports, "svg", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: function () { return signals.svg; }
|
|
34
|
-
});
|
|
35
27
|
Object.defineProperty(exports, "watch", {
|
|
36
28
|
enumerable: true,
|
|
37
29
|
get: function () { return signals.watch; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/cjs/production/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@lit-labs/signals");Object.defineProperty(exports,"
|
|
1
|
+
"use strict";var e=require("@lit-labs/signals");Object.defineProperty(exports,"Signal",{enumerable:!0,get:function(){return e.Signal}}),Object.defineProperty(exports,"SignalWatcher",{enumerable:!0,get:function(){return e.SignalWatcher}}),Object.defineProperty(exports,"WatchDirective",{enumerable:!0,get:function(){return e.WatchDirective}}),Object.defineProperty(exports,"computed",{enumerable:!0,get:function(){return e.computed}}),Object.defineProperty(exports,"signal",{enumerable:!0,get:function(){return e.signal}}),Object.defineProperty(exports,"watch",{enumerable:!0,get:function(){return e.watch}}),Object.defineProperty(exports,"withWatch",{enumerable:!0,get:function(){return e.withWatch}});//# sourceMappingURL=index.js.map
|
package/esm/development/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Signal, SignalWatcher, WatchDirective, computed, signal, watch, withWatch } from '@lit-labs/signals';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/esm/production/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{Signal,SignalWatcher,WatchDirective,computed,signal,watch,withWatch}from"@lit-labs/signals";//# sourceMappingURL=index.js.map
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { Signal } from 'signal-polyfill';
|
|
2
|
-
export {
|
|
2
|
+
export { Signal, SignalWatcher, WatchDirective, WatchDirectiveFunction, computed, signal, watch, withWatch } from '@lit-labs/signals';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @group signals
|
|
6
|
+
* @see {@link https://lit.dev/docs/data/signals/}
|
|
7
|
+
*/
|
|
4
8
|
type State<T> = Signal.State<T>;
|
|
9
|
+
/**
|
|
10
|
+
* @group signals
|
|
11
|
+
* @see {@link https://lit.dev/docs/data/signals/}
|
|
12
|
+
*/
|
|
13
|
+
type Computed<T> = Signal.Computed<T>;
|
|
5
14
|
|
|
6
|
-
export type { State };
|
|
15
|
+
export type { Computed, State };
|