Skip to content

Commit

Permalink
feat(Router): moved Add.attach + Remove.detach from Configure-only su…
Browse files Browse the repository at this point in the history
…pport to any Add/Remove context

affects: @tao.js/router

previously, only inside of Configure would a check be made for Add.attach to generate an Attach for
the same Route

this change puts the check in the {Route,Add,*} handler and returns {Route,Attach,o}
if true

provides the same for Remove.detach
  • Loading branch information
eudaimos committed Oct 22, 2018
1 parent 17f652d commit f216b37
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/tao-router/src/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,9 @@ export default class Router {
routes.forEach(({ Route, Add, Remove, Attach, Detach }) => {
if (Add) {
TAO.setCtx({ t: 'Route', a: 'Add', o: tao.o }, [Route, Add]);
if (Add.attach) {
Attach = Add;
}
}
if (Remove) {
TAO.setCtx({ t: 'Route', a: 'Remove', o: tao.o }, [Route, Remove]);
if (Remove.detach) {
Detach = Remove;
}
}
if (Attach) {
TAO.setCtx({ t: 'Route', a: 'Attach', o: tao.o }, [Route, Attach]);
Expand All @@ -173,6 +167,9 @@ export default class Router {
this._routes.set(trigram.key, handler);
console.log('route.add::trigram.unwrapCtx():', trigram.unwrapCtx());
TAO.addAsyncHandler(trigram.unwrapCtx(), handler);
if (Add.attach) {
return new AppCtx('Route', 'Attach', tao.o, Route, Add);
}
}
);
TAO.addInlineHandler(
Expand All @@ -187,6 +184,9 @@ export default class Router {
}
TAO.removeAsyncHandler(trigram.unwrapCtx(), routeHandler);
this._routes.delete(trigram.key);
if (Remove.detach) {
return new AppCtx('Route', 'Detach', tao.o, Route, Remove);
}
}
);
TAO.addInlineHandler(
Expand Down

0 comments on commit f216b37

Please sign in to comment.