Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui.js: Monitor parent context changes in child contexts #16

Open
tonyg opened this issue Dec 13, 2016 · 0 comments
Open

ui.js: Monitor parent context changes in child contexts #16

tonyg opened this issue Dec 13, 2016 · 0 comments

Comments

@tonyg
Copy link
Owner

tonyg commented Dec 13, 2016

ui.js: Monitor parent context changes in child contexts. There's a lot of faff in webchat.syndicate.js about publishing some HTML, waiting for it to appear, and then configuring some aspect of event listening or child HTML insertion. It'd be nice if the hierarchical UIFragment context identifiers could be used to allow all-at-once creation of resources and self-assembly of the DOM fragments and event handlers as their parents reconfigure themselves.

For example:

during inbound(uiTemplate("post-item.html", $postItemTemplate)) {
  during inbound(uiTemplate("post-item-" + contentClass + ".html", $entry)) {
    assert uiContext.html(containerSelector, Mustache.render(postItemTemplate, itemInfo));
    on asserted uiContext.fragmentVersion(_) {
      var innerContext = uiContext.context('item-body');
      assert innerContext.html('#' + itemId + ' .post-item-body-container',
                               Mustache.render(entry, itemInfo));
      if (!postInfo.isDraft) { /* ... */ }
    }
  }
}

could be rewritten as:

during inbound(uiTemplate("post-item.html", $postItemTemplate)) {
  during inbound(uiTemplate("post-item-" + contentClass + ".html", $entry)) {
    assert uiContext.html(containerSelector, Mustache.render(postItemTemplate, itemInfo));
    var innerContext = uiContext.context('item-body');
    assert innerContext.html('#' + itemId + ' .post-item-body-container',
                             Mustache.render(entry, itemInfo));
    if (!postInfo.isDraft) { /* ... */ }
  }
}

and the waiting-for-fragmentVersion would be done automatically in ui.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant