j-templates 7.0.15 → 7.0.17

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.
@@ -1,10 +1,14 @@
1
1
  import { IDestroyable } from "./utils.types";
2
+ import { Component } from "../Node/component";
2
3
  export declare function Computed<T extends WeakKey, K extends keyof T, V extends T[K]>(defaultValue: V): (target: T, propertyKey: K, descriptor: PropertyDescriptor) => PropertyDescriptor;
3
4
  export declare function ComputedAsync<T extends WeakKey, K extends keyof T, V extends T[K]>(defaultValue: V): (target: T, propertyKey: K, descriptor: PropertyDescriptor) => PropertyDescriptor;
4
5
  export declare function State(): any;
5
6
  export declare function Value(): any;
6
7
  export declare function Scope(): typeof ScopeDecorator;
7
8
  declare function ScopeDecorator<T, K extends string>(target: T, propertyKey: K, descriptor: PropertyDescriptor): PropertyDescriptor;
9
+ export declare function Inject<I, T extends Component>(type: {
10
+ new (...args: Array<any>): I;
11
+ }): (target: T, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
8
12
  export declare function Destroy(): typeof DestroyDecorator;
9
13
  export declare namespace Destroy {
10
14
  function All<T extends WeakKey, K>(value: T): void;
@@ -5,6 +5,7 @@ exports.ComputedAsync = ComputedAsync;
5
5
  exports.State = State;
6
6
  exports.Value = Value;
7
7
  exports.Scope = Scope;
8
+ exports.Inject = Inject;
8
9
  exports.Destroy = Destroy;
9
10
  const observableScope_1 = require("../Store/Tree/observableScope");
10
11
  const observableNode_1 = require("../Store/Tree/observableNode");
@@ -167,6 +168,23 @@ function ScopeDecorator(target, propertyKey, descriptor) {
167
168
  },
168
169
  };
169
170
  }
171
+ function Inject(type) {
172
+ return function () {
173
+ return InjectDecorator(type);
174
+ };
175
+ }
176
+ function InjectDecorator(type) {
177
+ return {
178
+ configurable: false,
179
+ enumerable: true,
180
+ get: function () {
181
+ return this.Injector.Get(type);
182
+ },
183
+ set: function (val) {
184
+ this.Injector.Set(type, val);
185
+ },
186
+ };
187
+ }
170
188
  function Destroy() {
171
189
  return DestroyDecorator;
172
190
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "j-templates",
3
- "version": "7.0.15",
3
+ "version": "7.0.17",
4
4
  "description": "j-templates",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/TypesInCode/jTemplates",