Skip to content

Commit

Permalink
refactor(testable): updated AppCtxHandlers so it doesn't have depende…
Browse files Browse the repository at this point in the history
…nce on De

affects: tao

Goal: make AppCtxHandlers more testable by not requiring a constructed De
- [x] removed injection of De (as taoRoot arg) into AppCtxHandlers ctor
- [x] removed get TAO prop from AppCtxHandlers
- [x] AppCtxHandlers.handleAppCon now accepts a setAppCtx function as second arg to set an AC when returned from handlers

BREAKING CHANGE:
AppCtxHandlers.handleAppCon now requires a 2nd arg passed to set the App Context in a De from
AppCtx's passed back from handlers
  • Loading branch information
eudaimos committed Mar 31, 2018
1 parent 67b6f63 commit 123e44c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 5 additions & 10 deletions packages/tao/src/AppCtxHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import AppCtx from './AppCtx';
import { isIterable } from './utils';

export default class AppCtxHandlers extends AppCtxRoot {
constructor(term, action, orient, taoRoot, leafAppConHandlers) {
constructor(term, action, orient, leafAppConHandlers) {
super(term, action, orient);

this._taoRoot = taoRoot;
this._leafAppConHandlers = new Set(leafAppConHandlers);
this._intercept = new Set();
this._async = new Set();
Expand Down Expand Up @@ -97,10 +96,6 @@ export default class AppCtxHandlers extends AppCtxRoot {

populateHandlersFromWildcards() {}

get TAO() {
return this._taoRoot;
}

get interceptHandlers() {
if (this._intercept) {
return this._intercept;
Expand All @@ -115,7 +110,7 @@ export default class AppCtxHandlers extends AppCtxRoot {
return this._inline;
}

async handleAppCon(ac) {
async handleAppCon(ac, setAppCtx) {
const { t, a, o, data } = ac;
/*
* Intercept Handlers
Expand All @@ -130,7 +125,7 @@ export default class AppCtxHandlers extends AppCtxRoot {
continue;
}
if (intercepted instanceof AppCtx) {
this.TAO.setAppCtx(intercepted);
setAppCtx(intercepted);
}
return;
}
Expand All @@ -153,7 +148,7 @@ export default class AppCtxHandlers extends AppCtxRoot {
Promise.resolve(asyncH({ t, a, o }, data))
.then(nextAc => {
if (nextAc && nextAc instanceof AppCtx) {
this.TAO.setAppCtx(nextAc);
setAppCtx(nextAc);
}
console.log(
`>>>>>>>> ending async context within ['${t}', '${a}', '${o}'] <<<<<<<<<<`
Expand Down Expand Up @@ -186,7 +181,7 @@ export default class AppCtxHandlers extends AppCtxRoot {
if (nextSpool.length) {
for (let nextAc of nextSpool) {
try {
this.TAO.setAppCtx(nextAc);
setAppCtx(nextAc);
} catch (error) {
console.error('error on next inline:', error);
}
Expand Down
1 change: 0 additions & 1 deletion packages/tao/src/De.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ function _addACHandler(
return taoHandlers.get(acKey);
}
const ach = new AppCtxHandlers(t, a, o);
// const ach = new AppCtxHandlers(t, a, o, tao);

if (ach.isWildcard) {
let leaves = new Set();
Expand Down

0 comments on commit 123e44c

Please sign in to comment.