@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 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
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- "use strict";var e=require("@lit-labs/signals");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,"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,"svg",{enumerable:!0,get:function(){return e.svg}}),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
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
@@ -1,2 +1,2 @@
1
- export { Computed, Signal, SignalWatcher, WatchDirective, computed, signal, svg, watch, withWatch } from '@lit-labs/signals';
1
+ export { Signal, SignalWatcher, WatchDirective, computed, signal, watch, withWatch } from '@lit-labs/signals';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- export{Computed,Signal,SignalWatcher,WatchDirective,computed,signal,svg,watch,withWatch}from"@lit-labs/signals";//# sourceMappingURL=index.js.map
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 { Computed, Signal, SignalWatcher, WatchDirective, WatchDirectiveFunction, computed, signal, svg, watch, withWatch } from '@lit-labs/signals';
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wirestate/lit-signals",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Signals re-exports for wirestate lit elements",
5
5
  "sideEffects": false,
6
6
  "author": "Syrotenko Igor",