first commit
This commit is contained in:
5
lib/components/timeline/action_constants.js
Normal file
5
lib/components/timeline/action_constants.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
RECEIVE_TIMELINE: 'RECEIVE_TIMELINE',
|
||||
}
|
||||
12
lib/components/timeline/actions.js
Normal file
12
lib/components/timeline/actions.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const {RECEIVE_TIMELINE} = require('./action_constants')
|
||||
|
||||
module.exports = {
|
||||
receivedTimeline: timeline => {
|
||||
return {
|
||||
type: RECEIVE_TIMELINE,
|
||||
items: timeline,
|
||||
}
|
||||
}
|
||||
}
|
||||
19
lib/components/timeline/proxy.js
Normal file
19
lib/components/timeline/proxy.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
const {receivedTimeline} = require('./actions')
|
||||
|
||||
module.exports = {
|
||||
// urls that should be called for the remote actions
|
||||
urls: {
|
||||
fetch: 'https://layla.amazon.de/api/cards?limit=50',
|
||||
},
|
||||
postHooks: {
|
||||
// called after the timeline has been fetched
|
||||
fetch: (store, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
store.dispatch(receivedTimeline(data.cards))
|
||||
resolve(data)
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
13
lib/components/timeline/reducer.js
Normal file
13
lib/components/timeline/reducer.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
const {RECEIVE_TIMELINE} = require('./action_constants')
|
||||
|
||||
module.exports = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case RECEIVE_TIMELINE:
|
||||
return Object.assign({}, state, {
|
||||
items: action.items
|
||||
})
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
7
lib/components/timeline/route.js
Normal file
7
lib/components/timeline/route.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
'/timeline': (store, params, cb) => {
|
||||
cb(store.getState().timeline.items)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user