Created
June 8, 2016 16:35
-
-
Save prenaudin/59d085e3487135dd673c600ae3226e7a to your computer and use it in GitHub Desktop.
Immutable.Record + React + Redux = ❤ - 5
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
// @flow | |
import Immutable from 'immutable'; | |
const defaultRecord = { | |
id: string; | |
done: boolean; | |
label: string; | |
createdAt: string; | |
updatedAt: string; | |
} = { | |
id: null, | |
done: false, | |
label: '', | |
createdAt: null, | |
updatedAt: null, | |
}; | |
const TaskRecord = Immutable.Record(defaultRecord) | |
class Task extends TaskRecord { | |
isDone() { | |
return this.get('done'); | |
} | |
getLabel() { | |
return this.get('label') || 'New Task'; | |
} | |
} | |
export default Task; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment