Created
March 22, 2017 16:53
-
-
Save stfcodes/2e24944bb48f447975ad6d8016914c0e to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Component.extend({ | |
| loadingIndicator: Ember.inject.service('loading-indicator'), | |
| classNames: ['loading-indicator'], | |
| classNameBindings: ['isLoading'], | |
| isLoading: false, | |
| init() { | |
| this._super(...arguments); | |
| Ember.run.once(this, function () { | |
| console.debug('[loading-indicator] Setting events...'); | |
| this.get('loadingIndicator').on('startLoading', this, this.startLoading); | |
| this.get('loadingIndicator').on('stopLoading', this, this.stopLoading); | |
| }); | |
| }, | |
| willDestroy() { | |
| Ember.run.once(this, function () { | |
| console.debug('[loading-indicator] Destroying events...'); | |
| this.get('loadingIndicator').off('startLoading', this, this.startLoading); | |
| this.get('loadingIndicator').off('stopLoading', this, this.stopLoading); | |
| }); | |
| }, | |
| startLoading() { | |
| console.debug('[loading-indicator] isLoading:true'); | |
| this.set('isLoading', true); | |
| }, | |
| stopLoading() { | |
| console.debug('[loading-indicator] isLoading:false'); | |
| this.set('isLoading', false); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| import config from './config/environment'; | |
| const Router = Ember.Router.extend({ | |
| location: 'none', | |
| rootURL: config.rootURL | |
| }); | |
| Router.map(function() { | |
| this.route('main', { path: '/' }, function() { | |
| this.route('slow-route', function() { | |
| this.route('foo'); | |
| this.route('bar'); | |
| }); | |
| }); | |
| }); | |
| export default Router; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| loadingIndicator: Ember.inject.service('loading-indicator'), | |
| doActivate: Ember.on('activate', function(){ | |
| console.log('application activating'); | |
| }), | |
| doDeactivate: Ember.on('deactivate', function(){ | |
| console.log('application deactivating'); | |
| }), | |
| actions: { | |
| willTransition() { | |
| this.get('loadingIndicator').start(); | |
| return true; | |
| }, | |
| didTransition() { | |
| this.get('loadingIndicator').stop(); | |
| return true; | |
| }, | |
| error() { | |
| this.get('loadingIndicator').stop(); | |
| return true; | |
| } | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| beforeModel() { | |
| return new Ember.RSVP.Promise((resolve) => { | |
| Ember.run.later(() => { | |
| resolve(); | |
| }, 1000); | |
| }); | |
| }, | |
| doActivate: Ember.on('activate', function(){ | |
| console.log('application.index activating'); | |
| }), | |
| doDeactivate: Ember.on('deactivate', function(){ | |
| console.log('application.index deactivating'); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| beforeModel() { | |
| return new Ember.RSVP.Promise((resolve) => { | |
| Ember.run.later(() => { | |
| resolve(); | |
| }, 1000); | |
| }); | |
| }, | |
| doActivate: Ember.on('activate', function(){ | |
| console.log('main activating'); | |
| }), | |
| doDeactivate: Ember.on('deactivate', function(){ | |
| console.log('main deactivating'); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| beforeModel() { | |
| return new Ember.RSVP.Promise((resolve, reject) => { | |
| Ember.run.later(() => { | |
| reject(); | |
| }, 1000); | |
| }); | |
| }, | |
| doActivate: Ember.on('activate', function(){ | |
| console.log('main.slow-route.bar activating'); | |
| }), | |
| doDeactivate: Ember.on('deactivate', function(){ | |
| console.log('main.slow-route.bar deactivating'); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| beforeModel() { | |
| return new Ember.RSVP.Promise((resolve) => { | |
| Ember.run.later(() => { | |
| resolve(); | |
| }, 1000); | |
| }); | |
| }, | |
| doActivate: Ember.on('activate', function(){ | |
| console.log('main.slow-route.foo activating'); | |
| }), | |
| doDeactivate: Ember.on('deactivate', function(){ | |
| console.log('main.slow-route.foo deactivating'); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Route.extend({ | |
| beforeModel() { | |
| return new Ember.RSVP.Promise((resolve) => { | |
| Ember.run.later(() => { | |
| resolve(); | |
| }, 1000); | |
| }); | |
| }, | |
| doActivate: Ember.on('activate', function(){ | |
| console.log('main.slow-route activating'); | |
| }), | |
| doDeactivate: Ember.on('deactivate', function(){ | |
| console.log('main.slow-route deactivating'); | |
| }) | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.Service.extend(Ember.Evented, { | |
| start() { | |
| console.debug('[loading-indicator] triggering:start'); | |
| this.trigger('startLoading'); | |
| }, | |
| stop() { | |
| console.debug('[loading-indicator] triggering:stop'); | |
| this.trigger('stopLoading'); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body { | |
| margin: 12px 16px; | |
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
| font-size: 12pt; | |
| } | |
| .loading-indicator { | |
| background-color: grey; | |
| color: white; | |
| text-align: center; | |
| } | |
| .is-loading { | |
| background-color: red; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "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-data": "2.12.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment