Last active
August 23, 2016 12:39
-
-
Save MiguelMadero/35eb6277981c685fbef58fa067369587 to your computer and use it in GitHub Desktop.
New Twiddle
This file contains 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({ | |
init () { | |
this._super(...arguments); | |
console.log(this.get('name') + " component init"); | |
}, | |
willInsertElement () { | |
console.log(this.get('name') + " component willInsertElement"); | |
}, | |
willClearRender () { | |
console.log(this.get('name') + " component willClearRender"); | |
}, | |
willDestroyElement () { | |
console.log(this.get('name') + " component willDestroyElement"); | |
} | |
}); | |
This file contains 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 {addV2Classes, addV1Classes} from 'twiddle/utils/use-v2'; | |
export default Ember.Component.extend({ | |
willInsertElement () { | |
this._super(...arguments); | |
addV2Classes(); | |
}, | |
willClearRender () { | |
this._super(...arguments); | |
// Unfortunately component hooks have a similar issue | |
//debugger; | |
addV1Classes(); | |
//debugger; | |
} | |
}); |
This file contains 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.Controller.extend({ | |
appName: 'Ember Twiddle', | |
}); |
This file contains 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('blog'); | |
this.route('with-component'); | |
}); | |
export default Router; |
This file contains 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({ | |
}); |
This file contains 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 {addV2Classes, addV1Classes} from 'twiddle/utils/use-v2'; | |
export default Ember.Route.extend({ | |
onActivate: function() { | |
addV2Classes(); | |
window.console.log('blog activate'); | |
}.on('activate'), | |
onDeActivate: function(){ | |
addV1Classes(); | |
// Adding a debugger statemeent here shows that the style is reset before we remove the content, so this is the *wrong* hook | |
// debugger | |
window.console.log('blog deactivate'); | |
}.on('deactivate'), | |
actions: { | |
willTransition: function() { | |
window.console.log('blog onWillTransition'); | |
}, | |
didTransition: function() { | |
window.console.log('blog onDidTransition'); | |
} | |
} | |
}); |
This file contains 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({ | |
onActivate: function() { | |
window.console.log('index activate'); | |
}.on('activate'), | |
onDeActivate: function(){ | |
window.console.log('index deactivate'); | |
}.on('deactivate'), | |
actions: { | |
willTransition: function() { | |
window.console.log('index onWillTransition'); | |
}, | |
didTransition: function() { | |
window.console.log('index onDidTransition'); | |
} | |
} | |
}); |
This file contains 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; | |
} | |
.v1 { | |
background: red; | |
} | |
.v2 { | |
background: yellow; | |
} |
This file contains 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.10.4", | |
"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.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
This file contains 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
let changeCounter = 0; | |
export function addV2Classes () { | |
changeCounter++; | |
$('.v1').toggleClass('v2 v1'); | |
} | |
export function addV1Classes () { | |
changeCounter-- | |
if (changeCounter === 0) { | |
$('.v2').toggleClass('v2 v1'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment