This file contains hidden or 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
| import React from 'react'; | |
| export type ReducerAction = Record<string, any> & { | |
| type: string; | |
| }; | |
| type Middleware = (a: ReducerAction) => void | Promise<void>; | |
| type Middlewares = Middleware[]; |
This file contains hidden or 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
| const userMiddleware = ({ getState, dispatch }) => next => async action => { | |
| const result = next(action); | |
| switch (action.type) { | |
| case SOME_ACTION: | |
| const asyncResult = await somethingAsync(); | |
| dispatch(anotherAction(asyncResult)); | |
| break; | |
| case SOME_OTHER_ACTION: | |
| const { slice: { stateVariable } } = getState(); | |
| await someProcess(stateVariable); |
This file contains hidden or 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
| import { InferableComponentEnhancerWithProps } from 'react-redux'; | |
| export default type ConnectedProps<T> = T extends InferableComponentEnhancerWithProps<infer Props, infer _> ? Props : never; | |
| // credit: https://github.com/Voronar |
This file contains hidden or 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
| // JunctionPoint.cs comes from | |
| // https://www.codeproject.com/Articles/15633/Manipulating-NTFS-Junction-Points-in-NET | |
| // | |
| // Full credit to Jeff Brown (https://www.codeproject.com/script/Membership/View.aspx?mid=1994253) | |
| using System; | |
| using System.IO; | |
| using System.Runtime.InteropServices; | |
| using System.Text; | |
| using Microsoft.Win32.SafeHandles; |
This file contains hidden or 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
| // | |
| // ReadPlist.m | |
| // | |
| #import <UIKit/UIKit.h> | |
| #import <React/RCTBridgeModule.h> | |
| #import <React/RCTUtils.h> | |
| #import <Foundation/NSData.h> | |
| #import <Foundation/Foundation.h> |
This file contains hidden or 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
| export const pushActionPromise = async (firebase, type, payload) => { | |
| // get the key for the new action about to be created | |
| const actionRef = firebase.database().ref('action'); | |
| const newKey = actionRef.push().key; | |
| // push the action | |
| const fullPayload = { | |
| uid: firebase.auth().currentUser.uid, | |
| type, | |
| payload, |
This file contains hidden or 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
| const syncedRetrievePromise = async ( | |
| ref, | |
| dispatchValue, | |
| dispatchKeyValue, | |
| ) => { | |
| // retrieve and dispatch the current value of the ref | |
| const data = await ref.once('value'); | |
| const val = data.val(); | |
| dispatchValue(val); | |