How to use the flux-standard-action.isError function in flux-standard-action

To help you get started, we’ve selected a few flux-standard-action examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / flux-standard-action / flux-standard-action-tests.ts View on Github external
function unwrapAction(action: { type: string }) {
    if (isFSA(action)) {
        if (isError(action)) {
            alert(action.payload!.message)
        }
        return action.payload
    }
}
github DefinitelyTyped / DefinitelyTyped / types / flux-standard-action / flux-standard-action-tests.ts View on Github external
}

var sample1: Action = {
    type: 'ADD_TODO',
    payload: {
        text: 'Do something.'
    }
};

var sample2: ErrorAction = {
    type: 'ADD_TODO',
    payload: new Error(),
    error: true
};

var result1: boolean = isError(sample1);
var result2: boolean = isFSA(sample1);
var result3: boolean = isError(sample2);
var result4: boolean = isFSA(sample2);

declare function alert (message: string): void

function unwrapAction(action: { type: string }) {
    if (isFSA(action)) {
        if (isError(action)) {
            alert(action.payload!.message)
        }
        return action.payload
    }
}

var result5: TextPayload = unwrapAction(sample1)
github DefinitelyTyped / DefinitelyTyped / types / flux-standard-action / flux-standard-action-tests.ts View on Github external
var sample1: Action = {
    type: 'ADD_TODO',
    payload: {
        text: 'Do something.'
    }
};

var sample2: ErrorAction = {
    type: 'ADD_TODO',
    payload: new Error(),
    error: true
};

var result1: boolean = isError(sample1);
var result2: boolean = isFSA(sample1);
var result3: boolean = isError(sample2);
var result4: boolean = isFSA(sample2);

declare function alert (message: string): void

function unwrapAction(action: { type: string }) {
    if (isFSA(action)) {
        if (isError(action)) {
            alert(action.payload!.message)
        }
        return action.payload
    }
}

var result5: TextPayload = unwrapAction(sample1)
var result6: Error = unwrapAction(sample2)
github retaxJS / retax-seed / src / store / asyncAwaitMiddleware.js View on Github external
const res = await asyncAwait;

        returnedAction = dispatch({
          ...getResolveAction(),
          ...(isFSA(res) ? res : {
            ...(!!res && { payload: res }),
          }),
        });

        if (isThunk(onResolve)) {
          await onResolve(res, store);
        }
      } catch (e) {
        returnedAction = dispatch({
          ...getResolveAction(true),
          ...(isError(e) ? e : {
            ...(!!e && { payload: e }),
          }),
        });

        if (isThunk(onReject)) {
          await onReject(e, store);
        }
      } finally {
        return returnedAction;
      }
    };
  };
github retaxJS / retax-seed / src / store / authMiddleware.js View on Github external
return next => action => {
    const shouldRedirect = isError(action) &&
      (action.payload.status === 401);

    if (shouldRedirect) {
      next(action);
      dispatch(removeAuthToken());
      return dispatch(push(SIGNIN));
    }

    return next(action);
  };
}

flux-standard-action

A human-friendly standard for Flux action objects

MIT
Latest version published 3 years ago

Package Health Score

62 / 100
Full package analysis

Popular flux-standard-action functions