Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...
- export const getAllTodos = () => {
- const todoList: Todo[] = [];
- return (dispatch: Function) => {
- return getDB().then((db: PouchDB.Database) =>
- // Demande des documents préfixés par 'todos'
- db.allDocs({
- startkey: 'todo',
- endkey: 'todo\ufff0',
- descending: false,
- include_docs: true
- })
- .then(data => {
- // Récupération des todos renvoyés par Pouch
- data.rows.map((item) => todoList.push(item.doc as Todo));
- // Envoie de la liste des todos au store
- dispatch({
- type: Action.GET_ALL_TODOS,
- todoList: fromJS(todoList)
- });
- })
- );
- };
- };
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement