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

Support async ts.ui.get(elm, callback) #268

Merged
merged 3 commits into from
May 10, 2017
Merged

Support async ts.ui.get(elm, callback) #268

merged 3 commits into from
May 10, 2017

Conversation

wiredearp
Copy link
Contributor

@wiredearp wiredearp commented May 10, 2017

@zdlm @sampi @rafalages @tstapleton

Fixes #258: Async ts.ui.get();

You can now pass a callback that will be executed

  • when the element gets spiritualized sometimes later; or
  • straight away, if the element is already spiritualized.

If the callback is provided, ts.ui.get returns nothing. If the callback is not provided, it works as usual. It could work something like this.

var button = document.createElement('button');
button.setAttribute('data-ts', 'Button');
ts.ui.get(button, spirit => {
    alert(spirit); // [object ts.ui.ButtonSpirit]
});
setTimeout(() => {
    document.body.appendChild(button); // trigger the callback
}, 1000);

The docs, or at least most of them, have been updated to use this fancy pattern. We should of course dedicate a whole page to explain this stuff in the Intro section somewhere and I've added the task to the Documentation project over on https://github.com/Tradeshift/tradeshift-ui/projects/4.

Also in PR: somewhere in docs, there was apparently a maximim callstack exceeded here and that seems to be correct, although not completely sure why it never happened before. This would affect the iPad breakpoint on menu navigation.

@wiredearp wiredearp changed the title Don't recurse to the end of time Support async ts.ui.get(elm, callback) May 10, 2017
@wiredearp wiredearp added this to the v8.0.0 milestone May 10, 2017
Copy link
Contributor

@zdlm zdlm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🅰️

@wiredearp wiredearp merged commit 9da2eb7 into master May 10, 2017
@wiredearp wiredearp deleted the jmo/docs branch May 10, 2017 15:25
@rafalages
Copy link

Great, thank you guys

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

Successfully merging this pull request may close these issues.

3 participants