-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a142cc6
commit 6aa2cd7
Showing
10 changed files
with
83 additions
and
34 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { FaveDispatcher } from '../dispatcher/FaveDispatcher'; | ||
import { FaveConstants } from '../constants/FaveConstants'; | ||
|
||
export var FaveActions = { | ||
addItem: function(item){ | ||
FaveDispatcher.handleAction({ | ||
actionType: FaveConstants.ADD_ITEM, | ||
data: item | ||
}); | ||
}, | ||
removeItem: function(index){ | ||
FaveDispatcher.handleAction({ | ||
actionType: FaveConstants.REMOVE_ITEM, | ||
data: index | ||
}) | ||
} | ||
}; | ||
|
||
// export FaveActions; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export var FaveConstants = { | ||
ADD_ITEM: "ADD_ITEM", | ||
REMOVE_ITEM: "REMOVE_ITEM" | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
var Dispatcher = require('flux').Dispatcher; | ||
export var FaveDispatcher = new Dispatcher(); | ||
|
||
FaveDispatcher.handleAction = function(action) { | ||
this.dispatch({ | ||
source: 'VIEW_ACTION', | ||
action: action | ||
}); | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { FaveDispatcher } from '../dispatcher/FaveDispatcher'; | ||
import { FaveConstants } from '../constants/FaveConstants'; | ||
var objectAssign = require('react/lib/Object.assign'); | ||
var EventEmitter = require('events').EventEmitter; | ||
var CHANGE_EVENT = 'change'; | ||
|
||
var _faveStore = { | ||
list: ['AirDrop', 'Applications', 'Desktop', 'Documents', 'Downloads', 'Pictures', 'User'] | ||
}; | ||
|
||
var addItem = function(item) { | ||
_faveStore.list.push(item); | ||
}; | ||
|
||
var removeItem = function(index) { | ||
_faveStore.list.splice(index, 1); | ||
} | ||
|
||
export var FaveStore = objectAssign({}, EventEmitter.prototype, { | ||
addChangeListener: function(cb) { | ||
this.on(CHANGE_EVENT, cb); | ||
}, | ||
removeChangeListener: function(cb) { | ||
this.removeListener(CHANGE_EVENT, cb); | ||
}, | ||
getList: function() { | ||
return _faveStore.list; | ||
} | ||
}); | ||
|
||
FaveDispatcher.register(function(payload) { | ||
var action = payload.action; | ||
switch (action.actionType) { | ||
case FaveConstants.ADD_ITEM: | ||
addItem(action.data); | ||
faveStore.emit(CHANGE_EVENT); | ||
break; | ||
case FaveConstants.REMOVE_ITEM: | ||
removeItem(action.data); | ||
faveStore.emit(CHANGE_EVENT); | ||
break; | ||
default: | ||
return true; | ||
} | ||
}); | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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