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 connect from 'ember-redux/routes/connect'; | |
const model = (dispatch, params) => { | |
return fetch(`/api/posts/${params.post_id}`).then(response => { | |
dispatch({ type: 'RECEIVE_POST', response }); | |
}); | |
}; | |
const stateToComputed = (state, params) => { |
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 hbs from 'htmlbars-inline-precompile'; | |
import { cashay } from 'cashay'; | |
const stateToComputed = (state) => { | |
const { userId } = state.routes.userDetailRoute.params; | |
const userQuery = ` | |
{ | |
user(id: ${userId}) { | |
id |
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 hbs from 'htmlbars-inline-precompile'; | |
import connect from 'ember-redux/components/connect'; | |
var stateToComputed = (state) => { | |
return { | |
number: state.number | |
}; | |
}; |
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
/** | |
A basic GraphQL query. | |
Using ember-redux, the result of the Cashay GraphQL query | |
is connected to the component. | |
*/ | |
import Ember from 'ember'; | |
import hbs from 'htmlbars-inline-precompile'; | |
import connect from 'ember-redux/components/connect'; |
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 hbs from 'htmlbars-inline-precompile'; | |
import connect from 'ember-redux/components/connect'; | |
import npmCashay from '../npm-shims/cashay'; | |
const { Component } = Ember; | |
const { cashay } = npmCashay; | |
const stateToComputed = () => { | |
const { users } = cashay.query(`{ users { id, name } }`).data; |
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
export default Route.extend({ | |
model() { | |
get(this, 'backend').fetch('users').then(users => { | |
// Pretend `.receive` is a helper method that does .dispatch({ type: 'RECEIVE', ...args }) | |
get(this, 'store').receive({ users }); | |
}) | |
} | |
}) |
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
export default Mixin.create({ | |
isSubscribedToStore: false, | |
store: service('redux'), | |
state: computed(function() { | |
return get(this, 'store').getState(); | |
}), | |
init() { |
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 connect from 'ember-redux/components/connect'; | |
var stateToComputed = (state) => { | |
return { | |
number: state.number | |
}; | |
}; | |
var dispatchToActions = (dispatch) => { |
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 connect from 'ember-redux/components/connect'; | |
import hbs from 'htmlbars-inline-precompile'; | |
export default Ember.Component.extend({ | |
layout: hbs`<h2>Hi there!</h2>` | |
}); |