@expressive/mvc 0.8.1 → 0.8.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.
package/lib/index.js CHANGED
@@ -25,7 +25,7 @@ function issues(register) {
25
25
  return Library;
26
26
  }
27
27
 
28
- const Oops$c = issues({
28
+ const Oops$d = issues({
29
29
  BadCallback: () => `Callback for effect-callback may only return a function.`
30
30
  });
31
31
  const { assign, create, defineProperty, entries, getPrototypeOf, getOwnPropertyNames, getOwnPropertyDescriptor, getOwnPropertySymbols, values } = Object;
@@ -38,7 +38,7 @@ function createEffect(callback) {
38
38
  if (unSet instanceof Promise)
39
39
  unSet = undefined;
40
40
  if (unSet && typeof unSet !== "function")
41
- throw Oops$c.BadCallback();
41
+ throw Oops$d.BadCallback();
42
42
  };
43
43
  }
44
44
  function createValueEffect(callback) {
@@ -54,15 +54,15 @@ function createValueEffect(callback) {
54
54
  if (typeof out == "function")
55
55
  unSet = out;
56
56
  else
57
- throw Oops$c.BadCallback();
57
+ throw Oops$d.BadCallback();
58
58
  };
59
59
  }
60
60
 
61
- const Oops$b = issues({
61
+ const Oops$c = issues({
62
62
  NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`,
63
63
  });
64
64
  function suspend(source, key) {
65
- const error = Oops$b.NotReady(source.subject, key);
65
+ const error = Oops$c.NotReady(source.subject, key);
66
66
  const promise = new Promise(resolve => {
67
67
  const release = source.addListener(forKey => {
68
68
  if (forKey == key)
@@ -102,7 +102,7 @@ function mayRetry(fn) {
102
102
  return compute();
103
103
  }
104
104
 
105
- const Oops$a = issues({
105
+ const Oops$b = issues({
106
106
  Failed: (parent, property, initial) => `An exception was thrown while ${initial ? "initializing" : "refreshing"} [${parent}.${property}].`
107
107
  });
108
108
  const INFO = new WeakMap();
@@ -119,7 +119,7 @@ function computeMode(self, source, setter, key, required) {
119
119
  return setter.call(sub.proxy, sub.proxy);
120
120
  }
121
121
  catch (err) {
122
- Oops$a.Failed(subject, key, initial).warn();
122
+ Oops$b.Failed(subject, key, initial).warn();
123
123
  throw err;
124
124
  }
125
125
  };
@@ -261,6 +261,7 @@ class Subscriber {
261
261
  }
262
262
 
263
263
  const REGISTER = new WeakMap();
264
+ const PENDING = new Map();
264
265
  class Control {
265
266
  constructor(subject) {
266
267
  this.subject = subject;
@@ -378,7 +379,6 @@ class Control {
378
379
  }
379
380
  }
380
381
 
381
- const PENDING = new Map();
382
382
  /**
383
383
  * Run instruction as controller sets itself up.
384
384
  * This will specialize the behavior of a given property.
@@ -489,7 +489,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
489
489
  });
490
490
  }
491
491
 
492
- const Oops$9 = issues({
492
+ const Oops$a = issues({
493
493
  DuplicatePending: (key) => `Invoked action ${key} but one is already active.`
494
494
  });
495
495
  function act(task) {
@@ -497,7 +497,7 @@ function act(task) {
497
497
  let pending = false;
498
498
  const invoke = (...args) => __awaiter(this, void 0, void 0, function* () {
499
499
  if (pending)
500
- return Promise.reject(Oops$9.DuplicatePending(key));
500
+ return Promise.reject(Oops$a.DuplicatePending(key));
501
501
  pending = true;
502
502
  this.update(key);
503
503
  try {
@@ -519,6 +519,9 @@ function act(task) {
519
519
  });
520
520
  }
521
521
 
522
+ const Oops$9 = issues({
523
+ NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`
524
+ });
522
525
  function factoryMode(self, output, key, required) {
523
526
  const { subject, state } = self;
524
527
  let pending;
@@ -540,7 +543,7 @@ function factoryMode(self, output, key, required) {
540
543
  const suspend = () => {
541
544
  if (required === false)
542
545
  return undefined;
543
- const issue = Oops$8.NotReady(subject, key);
546
+ const issue = Oops$9.NotReady(subject, key);
544
547
  assign(pending, {
545
548
  message: issue.message,
546
549
  stack: issue.stack
@@ -558,12 +561,8 @@ function factoryMode(self, output, key, required) {
558
561
  }
559
562
 
560
563
  const Oops$8 = issues({
561
- // BadSource: (model, property, got) =>
562
- // `Bad from-instruction provided to ${model}.${property}. Expects an arrow-function or a Model as source. Got ${got}.`,
563
564
  PeerNotAllowed: (model, property) => `Attempted to use an instruction result (probably use or tap) as computed source for ${model}.${property}. This is not possible.`,
564
565
  ComputeFailed: (model, key) => `Generating initial value for ${model}.${key} failed.`,
565
- NotReady: (model, key) => `Value ${model}.${key} value is not yet available.`,
566
- FactoryFailed: (model, key) => `Generating initial value for ${model}.${key} failed.`,
567
566
  Failed: (parent, property, initial) => `An exception was thrown while ${initial ? "initializing" : "refreshing"} [${parent}.${property}].`
568
567
  });
569
568
  function get(arg0, arg1, arg2) {
@@ -1297,10 +1296,10 @@ function useTap(source, arg1, arg2) {
1297
1296
  const instance = React.useMemo(() => {
1298
1297
  if (typeof source == "object")
1299
1298
  return () => source;
1300
- if (MVC.isTypeof(source))
1301
- return () => source.get(true);
1302
1299
  if (Model.isTypeof(source))
1303
- return () => useContext(source);
1300
+ return "get" in source
1301
+ ? () => source.get(true)
1302
+ : () => useContext(source);
1304
1303
  return source;
1305
1304
  }, [])();
1306
1305
  if (typeof arg1 == "function")