Created
August 17, 2016 01:14
-
-
Save matthewconstantine/fdab72d8e3040c48616312791ed24056 to your computer and use it in GitHub Desktop.
Component Factory
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'; | |
const NewPostModalSetup = Ember.Object.extend({ | |
isActive: false, | |
posts: null, | |
withOpenModal() { | |
return NewPostModalSetup.create({ | |
isActive: true | |
}); | |
}, | |
withDataLoading() { | |
return NewPostModalSetup.create({ | |
posts: Ember.RSVP.defer().promise | |
}); | |
}, | |
withDataLoaded() { | |
return NewPostModalSetup.create({ | |
posts: FactoryGuy.makeList('posts', 3) | |
}); | |
}, | |
render(context) { | |
context.setProperties({ | |
isActive: this.get('isActive'), | |
posts: this.get('posts'), | |
}); | |
context.render(hbs`{{new-post-modal | |
isActive=isActive | |
posts=posts | |
}}`) | |
} | |
}); | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle', | |
init() { | |
const x = NewPostModalSetup.create().withOpenModal().withDataLoading(); | |
console.log(x.posts); | |
} | |
}); |
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.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": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment