dothtml-interfaces 0.1.7 → 0.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dothtml-interfaces",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Dependency injection interfaces for DOTHtml.",
5
5
  "main": "src/index.d.ts",
6
6
  "types": "src/index.d.ts",
package/src/i-dot.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  import IComponent, { FrameworkItems } from "./i-component";
3
3
  import IDotCss, { IDotcssProp } from "./i-dot-css";
4
4
  import IEventBus from "./i-event-bus";
5
+ import IObservable from "./i-observable";
5
6
 
6
7
  type DotContentPrimitive = string|number|boolean;
7
8
  type DotContentBasic = DotContentPrimitive|Node|Element|NodeList|IComponent|IDotDocument//typeof DotDocument;
@@ -16,6 +17,11 @@ export interface IDotDocument
16
17
  // Internal use only:
17
18
  _appendOrCreateDocument(content: DotContent, parentEl?: Element, beforeNode?: Node|number);
18
19
 
20
+ /**
21
+ * A conditional function, analogous to if. Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
22
+ */
23
+ when(condition:IObservable|boolean, DotContent): IDotConditionalDocument;
24
+
19
25
  // Main functions.
20
26
  // TODO: please make this into a test case.
21
27
  /**
@@ -65,20 +71,6 @@ export interface IDotDocument
65
71
  * Executes a function immediately.
66
72
  */
67
73
  script(callback: Function): IDotDocument;
68
- /**
69
- * A conditional function, analogous to if. Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
70
- */
71
- when(condition:(()=>boolean)|boolean, callback: (()=>void)|DotContent): IDotDocument;
72
- /**
73
- * A conditional catch, analogous to else if. Can be used after a when function. Evaluates if the previous when's condition was false.
74
- * Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
75
- */
76
- otherwiseWhen(condition:(()=>boolean)|boolean, callback: (()=>void)|DotContent): IDotDocument;
77
- /**
78
- * A conditional final catch, analogous to else. Can be used after a when or otherwiseWhen function. Evaluates if the previous when/otherwiseWhen evaluated to false.
79
- * Renders the specified DOT if a condition is met. Dynamic binding is possible when callback is a function.
80
- */
81
- otherwise(callback: (()=>void)|DotContent): IDotDocument;
82
74
 
83
75
  scopeClass(prefix: number|string|null, content: DotContent): IDotDocument;
84
76
 
@@ -241,9 +233,26 @@ export interface IDotCore extends IDotDocument
241
233
  navigate(path: string, noHistory?: boolean, force?: boolean): void;
242
234
  css: IDotCss;
243
235
  bus: IEventBus;
236
+ window: IDotWindowBuilder;
244
237
 
245
238
  component<T extends {new(...args: any[]): (IComponent)}>(ComponentClass: T): T&{new(...args: any[]): ({$: FrameworkItems})};
239
+ }
246
240
 
241
+ export interface IDotWindowBuilder{
242
+ (content): Window;
243
+ }
244
+
245
+ export interface IDotConditionalDocument extends IDotDocument{
246
+ /**
247
+ * A conditional catch, analogous to else if. Can be used after a when function. Evaluates if the previous when's condition was false.
248
+ * Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
249
+ */
250
+ otherwiseWhen(condition:IObservable|boolean, callback: DotContent): IDotConditionalDocument;
251
+ /**
252
+ * A conditional final catch, analogous to else. Can be used after a when or otherwiseWhen function. Evaluates if the previous when/otherwiseWhen evaluated to false.
253
+ * Renders the specified DOT if a condition is met. Dynamic binding is possible when callback is a function.
254
+ */
255
+ otherwise(callback: DotContent): IDotDocument;
247
256
  }
248
257
 
249
258
  /**
@@ -260,6 +269,11 @@ export interface IDotElementDocument<T extends IDotDocument> extends IDotDocumen
260
269
  // TODO: I'd really like to enable this. Unfortunately it's not terribly easy to implement.
261
270
  // Might be impossible in ES5 (notwithstanding some possible hackery).
262
271
  //(content?: DotContent): IDotElementDocument<IDotGenericElement>;
272
+
273
+ /**
274
+ * A conditional function, analogous to if. Renders the specified DOT if a condition is met. Dynamic binding is possible when condition and callback are functions.
275
+ */
276
+ when(condition: IObservable|boolean, callback: DotContent): IDotConditionalDocument;
263
277
 
264
278
  // TODO: this will erase element context, which could be a bug.
265
279
  // It can be duplicated multiple times below, or find a new solution.
@@ -0,0 +1,18 @@
1
+ import { IDotDocument } from "./i-dot";
2
+
3
+
4
+ export default interface IObservable<Ti = any, To = Ti>{
5
+ // The untransformed value.
6
+ _value: Ti;
7
+ // Get the value.
8
+ getValue(): To;
9
+ // Set the value.
10
+ setValue(v: Ti);
11
+ // Optional transformer that can .
12
+ transformer?: (input: Ti)=>To;
13
+ subscribeNode(node: IDotDocument): number;
14
+ subscribeAttr(node: IDotDocument, attributeName: string): number;
15
+ subscribeCallback(node: IDotDocument): number;
16
+ detachBinding(id: number);
17
+ updateObservers(): void;
18
+ }
package/src/index.d.ts CHANGED
@@ -7,4 +7,5 @@ export * from "./i-dot-css";
7
7
 
8
8
  export { default as IComponent, FrameworkItems } from "./i-component";
9
9
 
10
+ export { default as IObservable } from "./i-observable";
10
11
  export { default as IEventBus } from "./i-event-bus";