ember-redux
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -0,1 +1,2 @@ | ||
import { defineProperty } from '@ember/object'; | ||
import { core, update, destroy } from './core'; | ||
@@ -6,3 +7,3 @@ import { inject } from '@ember/service'; | ||
WrappedComponent.prototype.redux = inject('redux'); | ||
defineProperty(WrappedComponent.prototype, 'redux', inject('redux')); | ||
@@ -9,0 +10,0 @@ return class Connect extends WrappedComponent { |
ember-redux Changelog | ||
============================== | ||
3.1.1 | ||
----- | ||
* [BUG]: WrappedComponent prototype injection now plays nice w/ ember 3.1 | ||
([#159](https://github.com/ember-redux/ember-redux/pull/159)) | ||
3.1.0 | ||
@@ -5,0 +11,0 @@ ----- |
@@ -31,3 +31,6 @@ --- | ||
const middleware = applyMiddleware(sagaMiddleware); | ||
const createStoreWithMiddleware = compose(middleware, enhancers)(createStore); | ||
const createStoreWithMiddleware = compose( | ||
middleware, | ||
enhancers | ||
)(createStore); | ||
const store = createStoreWithMiddleware(reducers); | ||
@@ -53,3 +56,5 @@ sagaMiddleware.run(root); | ||
var devtools = window.devToolsExtension ? window.devToolsExtension() : f => f; | ||
const devtools = window.devToolsExtension ? | ||
window.devToolsExtension() : | ||
f => f; | ||
@@ -67,5 +72,5 @@ export default compose(devtools); | ||
var resolved = thunk.default ? thunk.default : thunk; | ||
const resolved = thunk.default ? thunk.default : thunk; | ||
var warnz = function({dispatch, getState}) { | ||
const warnz = function({dispatch, getState}) { | ||
console.warn('wait!'); | ||
@@ -91,3 +96,5 @@ return next => action => { | ||
const createSaga = createSagaMiddleWare.default ? createSagaMiddleWare.default : createSagaMiddleWare; | ||
const createSaga = createSagaMiddleWare.default ? | ||
createSagaMiddleWare.default : | ||
createSagaMiddleWare; | ||
@@ -94,0 +101,0 @@ const sagaMiddleware = createSaga(); |
@@ -57,4 +57,9 @@ --- | ||
var model = (dispatch) => { | ||
return ajax('/api/users', 'GET').then(response => dispatch({type: 'DESERIALIZE_USERS', response: response})); | ||
const model = (dispatch) => { | ||
return ajax('/api/users', 'GET').then((response) => { | ||
dispatch({ | ||
type: 'DESERIALIZE_USERS', | ||
response | ||
})); | ||
} | ||
}; | ||
@@ -124,3 +129,3 @@ | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -131,9 +136,16 @@ users: state.users.all | ||
var dispatchToActions = (dispatch) => { | ||
const dispatchToActions = (dispatch) => { | ||
return { | ||
remove: (id) => fetch(`/api/users/${id}`, {method: 'DELETE'}).then(fetched => fetched.json()).then(response => dispatch({type: 'REMOVE_USER', id: id})) | ||
remove: (id) => fetch( | ||
`/api/users/${id}`, | ||
{ method: 'DELETE' } | ||
).then((fetched) => { | ||
fetched.json()).then((response) => { | ||
dispatch({ type: 'REMOVE_USER', id })); | ||
} | ||
} | ||
}; | ||
}; | ||
var UserListComponent = Ember.Component.extend({ | ||
const UserListComponent = Ember.Component.extend({ | ||
layout: hbs` | ||
@@ -144,3 +156,6 @@ {{users-table users=users remove=(action "remove")}} | ||
export default connect(stateToComputed, dispatchToActions)(UserListComponent); | ||
export default connect( | ||
stateToComputed, | ||
dispatchToActions | ||
)(UserListComponent); | ||
``` | ||
@@ -156,7 +171,9 @@ | ||
var UserTableComponent = Ember.Component.extend({ | ||
const UserTableComponent = Ember.Component.extend({ | ||
layout: hbs` | ||
{{#each users as |user|}} | ||
<div>{{user.name}}</div> | ||
<button onclick={{action remove user.id}}>remove</button> | ||
<button onclick={{action remove user.id}}> | ||
remove | ||
</button> | ||
{{/each}} | ||
@@ -180,3 +197,3 @@ ` | ||
var UserListComponent = Ember.Component.extend({ | ||
const UserListComponent = Ember.Component.extend({ | ||
layout: hbs` | ||
@@ -183,0 +200,0 @@ {{yield users (action "remove")}} |
@@ -25,3 +25,3 @@ --- | ||
Router.map(function() { | ||
this.route('restaurants', {path: '/'}); | ||
this.route('restaurants', { path: '/' }); | ||
}); | ||
@@ -37,3 +37,3 @@ ``` | ||
var model = dispatch => { | ||
const model = dispatch => { | ||
return fetch('/api/restaurants') | ||
@@ -76,3 +76,6 @@ .then(fetched => fetched.json()) | ||
case 'RESTAURANTS:TRANSFORM_LIST': { | ||
const restaurants = _.keyBy(action.response, restaurant => restaurant.id); | ||
const restaurants = _.keyBy( | ||
action.response, | ||
restaurant => restaurant.id | ||
); | ||
const merged = _.extend({}, state.all, restaurants); | ||
@@ -104,3 +107,3 @@ return Object.assign({}, state, {all: merged}); | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -151,3 +154,3 @@ restaurants: state.restaurants.all | ||
var model = (dispatch, params) => { | ||
const model = (dispatch, params) => { | ||
return fetch(`/api/restaurants/${params.id}`) | ||
@@ -170,3 +173,5 @@ .then(fetched => fetched.json()) | ||
case 'RESTAURANTS:TRANSFORM_DETAIL': { | ||
const restaurant = {[action.response.id]: action.response}; | ||
const restaurant = { | ||
[action.response.id]: action.response | ||
}; | ||
const merge = _.extend({}, state.all, restaurant); | ||
@@ -187,5 +192,23 @@ return Object.assign({}, state, { | ||
export default [ | ||
{id: 1, name: 'Tacopocalypse', reviews: [{id: 9, rating: 5}]}, | ||
{id: 2, name: 'Fuzzy’s Taco Shop', reviews: [{id: 8, rating: 3}]}, | ||
{id: 3, name: 'El Bait Shop', reviews: []} | ||
{ | ||
id: 1, | ||
name: 'Tacopocalypse', | ||
reviews: [{ | ||
id: 9, | ||
rating: 5 | ||
}] | ||
}, | ||
{ | ||
id: 2, | ||
name: 'Fuzzy’s Taco Shop', | ||
reviews: [{ | ||
id: 8, | ||
rating: 3 | ||
}] | ||
}, | ||
{ | ||
id: 3, | ||
name: 'El Bait Shop', | ||
reviews: [] | ||
} | ||
]; | ||
@@ -200,3 +223,7 @@ ``` | ||
{{#each-in restaurants as |key restaurant|}} | ||
<li>{{#link-to "restaurants.detail" restaurant.id}}{{restaurant.name}}{{/link-to}}</li> | ||
<li> | ||
{{#link-to "restaurants.detail" restaurant.id}} | ||
{{restaurant.name}} | ||
{{/link-to}} | ||
</li> | ||
{{/each-in}} | ||
@@ -227,5 +254,8 @@ </ul> | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
restaurant: _.get(state.restaurants.all, state.restaurants.selectedId) | ||
restaurant: _.get( | ||
state.restaurants.all, | ||
state.restaurants.selectedId | ||
) | ||
}; | ||
@@ -293,5 +323,7 @@ }; | ||
import { connect } from 'ember-redux'; | ||
import { getSelectedRestaurant } from '../reducers/restaurants'; | ||
import { | ||
getSelectedRestaurant | ||
} from '../reducers/restaurants'; | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -313,3 +345,3 @@ restaurant: getSelectedRestaurant(state) | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -366,6 +398,20 @@ restaurants: getRestaurants(state) | ||
case 'RESTAURANTS:TRANSFORM_LIST': { | ||
const normalized = normalize(action.response, [restaurantSchema]); | ||
const { restaurants, reviews } = normalized.entities; | ||
const merged = _.extend({}, state.all, _.keyBy(restaurants, r => r.id)); | ||
const mergedReviews = _.extend({}, state.reviews, _.keyBy(reviews, r => r.id)); | ||
const normalized = normalize( | ||
action.response, | ||
[restaurantSchema] | ||
); | ||
const { | ||
restaurants, | ||
reviews | ||
} = normalized.entities; | ||
const merged = _.extend( | ||
{}, | ||
state.all, | ||
_.keyBy(restaurants, r => r.id) | ||
); | ||
const mergedReviews = _.extend( | ||
{}, | ||
state.reviews, | ||
_.keyBy(reviews, r => r.id) | ||
); | ||
return Object.assign({}, state, { | ||
@@ -443,3 +489,3 @@ all: merged, | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -523,7 +569,10 @@ reviews: getReviews(state) | ||
import { connect } from 'ember-redux'; | ||
import { getReviews, getSelectedId } from '../reducers/restaurants'; | ||
import { | ||
getReviews, | ||
getSelectedId | ||
} from '../reducers/restaurants'; | ||
const { get } = Ember; | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -535,3 +584,3 @@ reviews: getReviews(state), | ||
var dispatchToActions = function(dispatch) { | ||
const dispatchToActions = function(dispatch) { | ||
return { | ||
@@ -554,3 +603,6 @@ rate: rating => { | ||
export default connect(stateToComputed, dispatchToActions)(Ember.Component); | ||
export default connect( | ||
stateToComputed, | ||
dispatchToActions | ||
)(Ember.Component); | ||
``` | ||
@@ -577,7 +629,23 @@ Now in the reducer we need to add that new selector | ||
case 'RESTAURANTS:RATE': { | ||
const restaurant = {[action.response.id]: action.response}; | ||
const normalized = normalize(restaurant, [restaurantSchema]); | ||
const { restaurants, reviews } = normalized.entities; | ||
const rateMerge = _.extend({}, state.all, restaurants); | ||
const rateReviews = _.extend({}, state.reviews, _.keyBy(reviews, r => r.id)); | ||
const restaurant = { | ||
[action.response.id]: action.response | ||
}; | ||
const normalized = normalize( | ||
restaurant, | ||
[restaurantSchema] | ||
); | ||
const { | ||
restaurants, | ||
reviews | ||
} = normalized.entities; | ||
const rateMerge = _.extend( | ||
{}, | ||
state.all, | ||
restaurants | ||
); | ||
const rateReviews = _.extend( | ||
{}, | ||
state.reviews, | ||
_.keyBy(reviews, r => r.id) | ||
); | ||
return Object.assign({}, state, { | ||
@@ -584,0 +652,0 @@ all: rateMerge, |
@@ -20,5 +20,5 @@ --- | ||
var { createStore } = Redux; | ||
const { createStore } = Redux; | ||
var store = createStore(); | ||
const store = createStore(); | ||
``` | ||
@@ -29,3 +29,3 @@ | ||
```js | ||
var reducer = ((state, action) => { | ||
const reducer = ((state, action) => { | ||
if(action.type === 'ADD') { | ||
@@ -47,5 +47,5 @@ return state + 1; | ||
var { createStore } = Redux; | ||
const { createStore } = Redux; | ||
var reducer = ((state, action) => { | ||
const reducer = ((state, action) => { | ||
if(action.type === 'ADD') { | ||
@@ -57,3 +57,3 @@ return state + 1; | ||
var store = createStore(reducer); | ||
const store = createStore(reducer); | ||
``` | ||
@@ -68,5 +68,5 @@ | ||
var { createStore } = Redux; | ||
const { createStore } = Redux; | ||
var reducer = ((state, action) => { | ||
const reducer = ((state, action) => { | ||
if(action.type === 'ADD') { | ||
@@ -78,3 +78,3 @@ return state + 1; | ||
var store = createStore(reducer); | ||
const store = createStore(reducer); | ||
@@ -98,5 +98,5 @@ export default Ember.Component.extend({ | ||
var { createStore } = Redux; | ||
const { createStore } = Redux; | ||
var reducer = ((state, action) => { | ||
const reducer = ((state, action) => { | ||
if(action.type === 'ADD') { | ||
@@ -108,3 +108,3 @@ return state + 1; | ||
var store = createStore(reducer); | ||
const store = createStore(reducer); | ||
@@ -136,5 +136,5 @@ export default Ember.Component.extend({ | ||
var { createStore } = Redux; | ||
const { createStore } = Redux; | ||
var reducer = ((state, action) => { | ||
const reducer = ((state, action) => { | ||
if(action.type === 'ADD') { | ||
@@ -146,3 +146,3 @@ return state + 1; | ||
var store = createStore(reducer); | ||
const store = createStore(reducer); | ||
@@ -149,0 +149,0 @@ export default Ember.Component.extend({ |
@@ -41,3 +41,3 @@ --- | ||
var stateToComputed = (state) => { | ||
const stateToComputed = (state) => { | ||
return { | ||
@@ -48,3 +48,3 @@ number: state.number | ||
var dispatchToActions = (dispatch) => { | ||
const dispatchToActions = (dispatch) => { | ||
return { | ||
@@ -55,3 +55,3 @@ add: () => dispatch({type: 'ADD'}) | ||
var NumbersComponent = Ember.Component.extend({ | ||
const NumbersComponent = Ember.Component.extend({ | ||
layout: hbs` | ||
@@ -63,3 +63,6 @@ {{number}} | ||
export default connect(stateToComputed, dispatchToActions)(NumbersComponent); | ||
export default connect( | ||
stateToComputed, | ||
dispatchToActions | ||
)(NumbersComponent); | ||
``` | ||
@@ -66,0 +69,0 @@ |
@@ -61,3 +61,6 @@ --- | ||
import { Restaurants } from '../types/restaurants'; | ||
import { ListDispatch, TRANSFORM_LIST } from '../actions/restaurants'; | ||
import { | ||
ListDispatch, | ||
TRANSFORM_LIST | ||
} from '../actions/restaurants'; | ||
@@ -287,3 +290,6 @@ const model = (dispatch: ListDispatch) => { | ||
import { RestaurantHash } from '../../types/restaurants'; | ||
import { DetailDispatch, TRANSFORM_DETAIL } from '../../actions/restaurants'; | ||
import { | ||
DetailDispatch, | ||
TRANSFORM_DETAIL | ||
} from '../../actions/restaurants'; | ||
@@ -294,3 +300,6 @@ type ParamsObject = { | ||
const model = (dispatch: DetailDispatch, params: ParamsObject) => { | ||
const model = ( | ||
dispatch: DetailDispatch, | ||
params: ParamsObject | ||
) => { | ||
return fetch(`/api/restaurants/${params.id}`) | ||
@@ -350,4 +359,12 @@ .then((fetched: Response) => fetched.json()) | ||
import _ from 'lodash'; | ||
import { Restaurant, RestaurantState } from '../types/restaurants'; | ||
import { TRANSFORM_LIST, TRANSFORM_DETAIL, DetailAction, ListAction } from '../actions/restaurants'; | ||
import { | ||
Restaurant, | ||
RestaurantState | ||
} from '../types/restaurants'; | ||
import { | ||
TRANSFORM_LIST, | ||
TRANSFORM_DETAIL, | ||
DetailAction, | ||
ListAction | ||
} from '../actions/restaurants'; | ||
@@ -364,9 +381,26 @@ const initialState = { | ||
case TRANSFORM_LIST: { | ||
const restaurants = _.keyBy(action.response, (restaurant: Restaurant) => restaurant.id); | ||
const merged = _.extend({}, state.all, restaurants); | ||
return Object.assign({}, state, {all: merged}); | ||
const restaurants = _.keyBy( | ||
action.response, | ||
(restaurant: Restaurant) => restaurant.id | ||
); | ||
const merged = _.extend( | ||
{}, | ||
state.all, | ||
restaurants | ||
); | ||
return Object.assign( | ||
{}, | ||
state, | ||
{ all: merged } | ||
); | ||
} | ||
case TRANSFORM_DETAIL: { | ||
const restaurant = {[action.response.id]: action.response}; | ||
const merge = _.extend({}, state.all, restaurant); | ||
const restaurant = { | ||
[action.response.id]: action.response | ||
}; | ||
const merge = _.extend( | ||
{}, | ||
state.all, | ||
restaurant | ||
); | ||
return Object.assign({}, state, { | ||
@@ -373,0 +407,0 @@ all: merge, |
{ | ||
"name": "ember-redux", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "ember-cli addon that provides simple redux bindings for ember.js", | ||
@@ -30,3 +30,3 @@ "directories": { | ||
"broccoli-asset-rev": "^2.4.5", | ||
"ember-cli": "~2.18.0", | ||
"ember-cli": "3.1.2", | ||
"ember-cli-dependency-checker": "^2.0.0", | ||
@@ -45,3 +45,3 @@ "ember-cli-eslint": "^4.2.1", | ||
"ember-lodash-shim": "^2.0.5", | ||
"ember-maybe-import-regenerator": "0.1.4", | ||
"ember-maybe-import-regenerator": "0.1.6", | ||
"ember-qunit-assert-helpers": "^0.2.0", | ||
@@ -52,7 +52,7 @@ "ember-redux-saga-shim": "2.0.0", | ||
"ember-resolver": "^4.0.0", | ||
"ember-source": "~2.18.0", | ||
"ember-source": "3.1.0", | ||
"ember-try": "^0.2.23", | ||
"eslint-plugin-ember": "^5.0.0", | ||
"eslint-plugin-node": "^5.2.1", | ||
"eslint-plugin-node": "^6.0.1", | ||
"ember-symbol-observable": "^1.0.0", | ||
"eslint-plugin-ember": "^4.5.0", | ||
"loader.js": "^4.2.3", | ||
@@ -59,0 +59,0 @@ "redux": "^3.7.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
375346
402
1054
0
30