Fully operational mopidy middleware; Spotify middleware next
This commit is contained in:
30
src/js/services/spotify/actions.js
Executable file
30
src/js/services/spotify/actions.js
Executable file
@ -0,0 +1,30 @@
|
||||
|
||||
/**
|
||||
* Actions and Action Creators
|
||||
**/
|
||||
|
||||
export function authorize(){
|
||||
return {
|
||||
type: 'SPOTIFY_AUTHORIZING'
|
||||
}
|
||||
}
|
||||
|
||||
export function connect(){
|
||||
return {
|
||||
type: 'SPOTIFY_CONNECTING'
|
||||
}
|
||||
}
|
||||
|
||||
export function disconnect(){
|
||||
return {
|
||||
type: 'SPOTIFY_DISCONNECT'
|
||||
}
|
||||
}
|
||||
|
||||
export function loadAlbum( uri ){
|
||||
return {
|
||||
type: 'SPOTIFY_LOAD_ALBUM',
|
||||
uri: uri
|
||||
}
|
||||
}
|
||||
|
||||
28
src/js/services/spotify/middleware.js
Executable file
28
src/js/services/spotify/middleware.js
Executable file
@ -0,0 +1,28 @@
|
||||
|
||||
import actions from './actions'
|
||||
|
||||
const SpotifyMiddleware = (function(){
|
||||
|
||||
return store => next => action => {
|
||||
|
||||
switch(action.type) {
|
||||
|
||||
case 'SPOTIFY_CONNECT':
|
||||
|
||||
console.log('Spotify wants to connect')
|
||||
|
||||
break;
|
||||
|
||||
case 'SPOTIFY_DISCONNECT':
|
||||
console.log('Spotify wants to DISconnect')
|
||||
break;
|
||||
|
||||
// This action is irrelevant to us, pass it on to the next middleware
|
||||
default:
|
||||
return next(action);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
export default SpotifyMiddleware
|
||||
23
src/js/services/spotify/reducer.js
Executable file
23
src/js/services/spotify/reducer.js
Executable file
@ -0,0 +1,23 @@
|
||||
|
||||
export default function reducer(spotify = {}, action){
|
||||
switch (action.type) {
|
||||
|
||||
case 'SPOTIFY_CONNECTING':
|
||||
return Object.assign({}, spotify, { connected: false, connecting: true });
|
||||
|
||||
case 'SPOTIFY_AUTHORIZING':
|
||||
return Object.assign({}, spotify, { authorizing: true });
|
||||
|
||||
case 'SPOTIFY_CONNECTED':
|
||||
return Object.assign({}, spotify, { connected: true, connecting: false });
|
||||
|
||||
case 'SPOTIFY_DISCONNECTED':
|
||||
return Object.assign({}, spotify, { connected: false, connecting: false });
|
||||
|
||||
default:
|
||||
return spotify
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user