@wirestate/lit-signals 0.6.0 → 0.7.0-experimental.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 +21 -1
- package/README.md +53 -1
- 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,23 @@
|
|
|
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
|
+
- Export missing methods typing for `@wirestate/core`
|
|
12
|
+
- Extensive JSDoc coverage for wirestate packages
|
|
13
|
+
- `createIocContainer`: Added ability to instantly provide and activate entries, targeted seeds
|
|
14
|
+
- `createInjectablesProvider`: Removed.
|
|
15
|
+
- `IocProvider`: Removed
|
|
16
|
+
- `useRootContainer`: Added separate hook for store management in React tree
|
|
17
|
+
- `ContainerProvider`: Simpler provider for containers.
|
|
18
|
+
- `SubContainerProvider`: Added component solving problems of removed `createInjectablesProvider`
|
|
19
|
+
- `ContainerActivator`: Added separate activation component
|
|
20
|
+
|
|
1
21
|
## 0.6.3
|
|
2
22
|
|
|
3
23
|
- Update readme files for each module
|
|
@@ -59,6 +79,6 @@
|
|
|
59
79
|
- useService -> useInjection
|
|
60
80
|
- AbstractService::getService -> AbstractService::resolve
|
|
61
81
|
|
|
62
|
-
## 0.1.
|
|
82
|
+
## 0.1.0
|
|
63
83
|
|
|
64
84
|
- Initial release
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @wirestate/lit-signals
|
|
1
|
+
# @wirestate/lit-signals [[monorepo](https://github.com/Neloreck/wirestate)] [[docs](https://neloreck.github.io/wirestate/)]
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@wirestate/lit-signals)
|
|
4
4
|
[](https://github.com/Neloreck/wirestate/blob/master/LICENSE)
|
|
@@ -11,6 +11,58 @@ 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 { signal, computed, watch, Signal, State, Computed } from "@wirestate/lit-signals";
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Example service:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { Injectable, Inject, WireScope } from "@wirestate/core";
|
|
24
|
+
import { signal, computed, State, Computed } from "@wirestate/lit-signals";
|
|
25
|
+
|
|
26
|
+
@Injectable()
|
|
27
|
+
export class CounterService {
|
|
28
|
+
public readonly count: State<number> = signal(0);
|
|
29
|
+
public readonly isEven: Computed<boolean> = computed(() => this.count.get() % 2 === 0);
|
|
30
|
+
|
|
31
|
+
public constructor(@Inject(WireScope) private scope: WireScope) {}
|
|
32
|
+
|
|
33
|
+
public increment(): void {
|
|
34
|
+
this.count.set(this.count.get() + 1);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Example Lit element:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { LitElement, html } from "lit";
|
|
43
|
+
import { customElement } from "lit/decorators.js";
|
|
44
|
+
import { injection } from "@wirestate/lit";
|
|
45
|
+
import { watch, computed } from "@wirestate/lit-signals";
|
|
46
|
+
|
|
47
|
+
import { CounterService } from "./services";
|
|
48
|
+
|
|
49
|
+
@customElement("my-component")
|
|
50
|
+
class MyComponent extends LitElement {
|
|
51
|
+
@injection({ injectionId: CounterService })
|
|
52
|
+
private readonly counterService!: CounterService;
|
|
53
|
+
|
|
54
|
+
private isOddLabel = computed(() => (this.counterService.count.get() % 2 === 0 ? "even" : "odd"));
|
|
55
|
+
|
|
56
|
+
render() {
|
|
57
|
+
return html`
|
|
58
|
+
<button @click="${() => this.counterService.increment()}">
|
|
59
|
+
count: ${watch(this.counterService.count)} (${watch(this.isOddLabel)})
|
|
60
|
+
</button>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
14
66
|
## License
|
|
15
67
|
|
|
16
68
|
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 };
|