first commit
This commit is contained in:
5
lib/components/network/action_constants.js
Normal file
5
lib/components/network/action_constants.js
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
RECEIVE_NETWORK: 'RECEIVE_NETWORK',
|
||||
}
|
||||
12
lib/components/network/actions.js
Normal file
12
lib/components/network/actions.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const {RECEIVE_NETWORK} = require('./action_constants')
|
||||
|
||||
module.exports = {
|
||||
receivedNetwork: network => {
|
||||
return {
|
||||
type: RECEIVE_NETWORK,
|
||||
network,
|
||||
}
|
||||
}
|
||||
}
|
||||
21
lib/components/network/proxy.js
Normal file
21
lib/components/network/proxy.js
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict'
|
||||
|
||||
const {receivedNetwork} = require('./actions')
|
||||
|
||||
module.exports = {
|
||||
// urls that should be called for the remote actions
|
||||
urls: {
|
||||
fetch: 'https://layla.amazon.de/api/phoenix',
|
||||
discover: 'https://layla.amazon.de/api/phoenix/discovery',
|
||||
},
|
||||
// called after an remote http call to the network API has been successfully executed
|
||||
postHooks: {
|
||||
// called after the network data has been fetched
|
||||
fetch: (store, data) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
store.dispatch(receivedNetwork(JSON.parse(data.networkDetail)))
|
||||
resolve(data)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
13
lib/components/network/reducer.js
Normal file
13
lib/components/network/reducer.js
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
const {RECEIVE_NETWORK} = require('./action_constants')
|
||||
|
||||
module.exports = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case RECEIVE_NETWORK:
|
||||
return Object.assign({}, state, {
|
||||
network: action.network
|
||||
})
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
7
lib/components/network/route.js
Normal file
7
lib/components/network/route.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
'/network': (store, params, cb) => {
|
||||
res.send(store.getState().network.network)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user