Skip to content

Instantly share code, notes, and snippets.

@feanor07
Created April 24, 2017 12:44
Show Gist options
  • Save feanor07/6d469dd60903c9d06516cf93e6ecbc0b to your computer and use it in GitHub Desktop.
Save feanor07/6d469dd60903c9d06516cf93e6ecbc0b to your computer and use it in GitHub Desktop.
so#43580683
import Ember from 'ember';
export default Ember.Component.extend({
isDoneWithHeavyWork: false,
init() {
this._super(...arguments);
console.log('I am doing some serious stuff currently wait 3 seconds before showing me!');
window.setTimeout(()=> {
this.set('isDoneWithHeavyWork', true);
this.get('doneInitializng')();
}, 3000);
}
});
import Ember from 'ember';
export default Ember.Component.extend({
isDoneWithHeavyWork: false,
init() {
this._super(...arguments);
console.log('I am doing some serious stuff currently wait 10 seconds before showing me!');
window.setTimeout(()=> {
this.set('isDoneWithHeavyWork', true);
this.get('doneInitializng')();
}, 10000);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
actions: {
componentAtTabDoneInitializing(tabIndex) {
this.set(`tab${tabIndex}FinishedInitializing`, true);
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
{{#bs-tab customTabs=true as |tab|}}
{{#bs-nav type="tabs" as |nav|}}
{{#nav.item active=(bs-eq tab.activeId "edit")}}<a href="#pane1" role="tab" {{action tab.select "edit"}}>Tab 1</a>{{/nav.item}}
{{#nav.item active=(bs-eq tab.activeId "edit2")}}<a href="#pane1" role="tab" {{action tab.select "edit2"}}>Tab 2 <span class="badge">{{badge}}</span></a>{{/nav.item}}
{{/bs-nav}}
<div class="tab-content">
{{#tab.pane elementId="edit" title="Edit"}}
{{#if tab1FinishedInitializing}}
<h2>TAB 1 Component DONE with initializing</h2>
{{/if}}
{{my-component doneInitializng=(action 'componentAtTabDoneInitializing' 1)}}
{{/tab.pane}}
{{#tab.pane elementId="edit2" title="Edit2"}}
{{#if tab2FinishedInitializing}}
<h2>TAB 2 Component DONE with initializing</h2>
{{/if}}
{{my-component2 doneInitializng=(action 'componentAtTabDoneInitializing' 2)}}
{{/tab.pane}}
</div>
{{/bs-tab}}
<br>
<br>
{{yield}}
{{#if isDoneWithHeavyWork}}
Great, I am done with the heavy work!!!
{{else}}
Wait please; I am not done with heavy work at init that will t ake 3 seconds!!
{{/if}}
{{yield}}
{{#if isDoneWithHeavyWork}}
Great, I am done with the heavy work!!!
{{else}}
Wait please; I am not done with heavy work at init that will take 10 seconds!!
{{/if}}
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-bootstrap":"1.0.0-alpha.11"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment