@expressive/mvc 0.21.3 → 0.21.7

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/lib/index.d.ts CHANGED
@@ -71,7 +71,7 @@ declare namespace Control {
71
71
  */
72
72
  type OnReady<T extends Model> = (control: Control<T>) => Callback | void;
73
73
  type RequestRefresh = (update: (tick: number) => number) => void;
74
- type HasHook = (type: typeof Model, relativeTo: Model, callback: (got: Model | undefined) => void) => void;
74
+ type GetContext = (target: Model) => (callback: (got: Context) => void) => void;
75
75
  type GetAdapter<T> = (refresh: RequestRefresh, context: Context) => {
76
76
  mount: () => (() => void) | void;
77
77
  render: () => T;
@@ -92,7 +92,7 @@ declare class Control<T extends Model = any> {
92
92
  static pending: Set<Callback>;
93
93
  static get: Control.GetHook;
94
94
  static use: Control.UseHook;
95
- static has: Control.HasHook;
95
+ static has: Control.GetContext;
96
96
  static for: typeof control;
97
97
  static apply: typeof apply;
98
98
  static watch: typeof watch;
package/lib/index.esm.js CHANGED
@@ -659,12 +659,16 @@ function get(arg0, arg1) {
659
659
  if (!hasParent) {
660
660
  if (arg1 === true)
661
661
  throw Oops$3.Required(arg0, subject);
662
- source = callback => Control.has(arg0, subject, got => {
663
- if (got)
664
- callback(got);
665
- else if (arg1 !== false)
666
- throw Oops$3.AmbientRequired(arg0, subject);
667
- });
662
+ const fetch = Control.has(subject);
663
+ source = got => {
664
+ fetch(context => {
665
+ const model = context.get(arg0);
666
+ if (model)
667
+ got(model);
668
+ else if (arg1 !== false)
669
+ throw Oops$3.AmbientRequired(arg0, subject);
670
+ });
671
+ };
668
672
  }
669
673
  else if (!arg0 || hasParent instanceof arg0)
670
674
  subject = hasParent;
package/lib/index.js CHANGED
@@ -663,12 +663,16 @@ function get(arg0, arg1) {
663
663
  if (!hasParent) {
664
664
  if (arg1 === true)
665
665
  throw Oops$3.Required(arg0, subject);
666
- source = callback => Control.has(arg0, subject, got => {
667
- if (got)
668
- callback(got);
669
- else if (arg1 !== false)
670
- throw Oops$3.AmbientRequired(arg0, subject);
671
- });
666
+ const fetch = Control.has(subject);
667
+ source = got => {
668
+ fetch(context => {
669
+ const model = context.get(arg0);
670
+ if (model)
671
+ got(model);
672
+ else if (arg1 !== false)
673
+ throw Oops$3.AmbientRequired(arg0, subject);
674
+ });
675
+ };
672
676
  }
673
677
  else if (!arg0 || hasParent instanceof arg0)
674
678
  subject = hasParent;
package/package.json CHANGED
@@ -27,5 +27,5 @@
27
27
  "preversion": "npm run test && npm run build",
28
28
  "postversion": "git push & npm publish"
29
29
  },
30
- "version": "0.21.3"
30
+ "version": "0.21.7"
31
31
  }