@joist/di 3.0.0-next.1 → 3.0.0-next.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.
Files changed (2) hide show
  1. package/README.md +6 -8
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -23,7 +23,7 @@ class FooService {
23
23
  class BarService {
24
24
  static inject = [FooService];
25
25
 
26
- constructor(private foo: Injected<FooService>) { }
26
+ constructor(public foo: Injected<FooService>) { }
27
27
 
28
28
  sayHello() {
29
29
  return this.foo().sayHello();
@@ -49,7 +49,7 @@ class FooService {
49
49
  class BarService {
50
50
  static inject = [FooService];
51
51
 
52
- constructor(private foo: Injected<FooService>) {}
52
+ constructor(public foo: Injected<FooService>) {}
53
53
 
54
54
  sayHello() {
55
55
  return 'Hello From BarService and ' + this.foo().sayHello();
@@ -73,13 +73,12 @@ app.get(BarService).sayHello(); // Hello from BarService and IT HAS BEEN OVERRID
73
73
 
74
74
  #### Root Service
75
75
 
76
- If you have nested injectors and you want to make sure the same instance is provided to all decorate your service with `@service()`.
76
+ If you have nested injectors and you want to make sure the same instance is provided to all you can mark your class as a "service".
77
77
 
78
78
  ```TS
79
- import { service } from '@joist/di';
80
-
81
- @service
82
79
  class FooService {
80
+ static service = true;
81
+
83
82
  sayHello() {
84
83
  return 'Hello From FooService';
85
84
  }
@@ -94,8 +93,6 @@ Since the browser will be what initializes your custom elements we need to be ab
94
93
 
95
94
  The `@injectable` decorator allows the Joist Dependency Injector to pass arguments to your custom element when instances of your element is created.
96
95
 
97
- `@injectable` also injects your services in a lazy way. Instead of passing direct instances of your services it passes a function that be called when you need your service instance. This allows the injector to look for parent injectors which are only availabel after connectedCallback.
98
-
99
96
  #### Inject dependency into your custom element constructor
100
97
 
101
98
  ```TS
@@ -183,6 +180,7 @@ class MyElement extends HTMLElement {
183
180
  }
184
181
 
185
182
  connectedCallback() {
183
+ // run in connected callback so your element can check its parents
186
184
  const { primary } = this.colors();
187
185
 
188
186
  this.style.background = primary;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joist/di",
3
- "version": "3.0.0-next.1",
3
+ "version": "3.0.0-next.2",
4
4
  "main": "./target/lib.js",
5
5
  "module": "./target/lib.js",
6
6
  "exports": {