-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
15 changed files
with
410 additions
and
144 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 |
---|---|---|
@@ -1,9 +1,21 @@ | ||
/** | ||
* @format | ||
*/ | ||
|
||
import {AppRegistry} from 'react-native'; | ||
import App from './src/App'; | ||
import {name as appName} from './app.json'; | ||
|
||
AppRegistry.registerComponent(appName, () => App); | ||
import getStore from './src/store'; | ||
import {PersistGate} from 'redux-persist/integration/react'; | ||
import {Provider} from 'react-redux'; | ||
|
||
const {store, persistor} = getStore(); | ||
|
||
const ReduxProvider = () => { | ||
return ( | ||
<Provider store={store}> | ||
<PersistGate loading={null} persistor={persistor}> | ||
<App /> | ||
</PersistGate> | ||
</Provider> | ||
); | ||
}; | ||
|
||
AppRegistry.registerComponent(appName, () => ReduxProvider); |
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
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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {AppActionType, AppActionTypes, NoteObject} from './app.types'; | ||
|
||
export const notesPending = (): AppActionType => ({ | ||
type: AppActionTypes.NOTES_PENDING, | ||
}); | ||
|
||
export const notesSuccess = (notes: NoteObject[]): AppActionType => ({ | ||
type: AppActionTypes.NOTES_SUCCESS, | ||
payload: notes, | ||
}); | ||
|
||
export const notesFailed = (): AppActionType => ({ | ||
type: AppActionTypes.NOTES_FAILED, | ||
}); | ||
|
||
export const createNote = (note: NoteObject): AppActionType => ({ | ||
type: AppActionTypes.CREATE, | ||
payload: note, | ||
}); | ||
|
||
export const deleteNote = (id: string): AppActionType => ({ | ||
type: AppActionTypes.DELETE, | ||
payload: id, | ||
}); | ||
|
||
export const updateNote = (note: NoteObject): AppActionType => ({ | ||
type: AppActionTypes.UPDATE, | ||
payload: note, | ||
}); |
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,41 @@ | ||
import {Effect} from '../index'; | ||
import { | ||
notesFailed, | ||
notesSuccess, | ||
notesPending, | ||
createNote, | ||
deleteNote, | ||
updateNote, | ||
} from './index'; | ||
|
||
import {NoteObject} from './app.types'; | ||
|
||
export const initialize = | ||
(): Effect<Promise<any>> => async (dispatch, getState) => { | ||
const {APP} = getState(); | ||
dispatch(notesPending()); | ||
try { | ||
const notes = APP.notes; | ||
dispatch(notesSuccess(notes)); | ||
} catch (error: any) { | ||
dispatch(notesFailed()); | ||
} | ||
}; | ||
|
||
export const create = | ||
(note: NoteObject): Effect<void> => | ||
async (dispatch, getState) => { | ||
dispatch(createNote(note)); | ||
}; | ||
|
||
export const remove = | ||
(id: string): Effect<void> => | ||
async (dispatch, getState) => { | ||
dispatch(deleteNote(id)); | ||
}; | ||
|
||
export const update = | ||
(note: NoteObject): Effect<void> => | ||
async (dispatch, getState) => { | ||
dispatch(updateNote(note)); | ||
}; |
Oops, something went wrong.