How to use the flux-standard-action.isFSA 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 redux-form / redux-form / src / __tests__ / actions.spec.js View on Github external
it('should create clear submit errors action', () => {
    expect(clearSubmitErrors('myForm')).toEqual({
      type: CLEAR_SUBMIT_ERRORS,

      meta: {
        form: 'myForm'
      }
    })

    expect(isFSA(clearSubmitErrors('myForm'))).toBe(true)
  })
github redux-form / redux-form / src / __tests__ / actions.spec.js View on Github external
it('should create stopSubmit action', () => {
    expect(stopSubmit('myForm')).toEqual({
      type: STOP_SUBMIT,

      meta: {
        form: 'myForm'
      },

      payload: undefined,
      error: false
    })

    expect(isFSA(stopSubmit('myForm'))).toBe(true)
    const errors = {
      foo: 'Foo error',
      bar: 'Error for bar'
    }

    expect(stopSubmit('myForm', errors)).toEqual({
      type: STOP_SUBMIT,

      meta: {
        form: 'myForm'
      },

      payload: errors,
      error: true
    })
github redux-form / redux-form / src / __tests__ / actions.spec.js View on Github external
it('should create array insert action', () => {
    expect(arrayInsert('myForm', 'myField', 0, 'foo')).toEqual({
      type: ARRAY_INSERT,

      meta: {
        form: 'myForm',
        field: 'myField',
        index: 0
      },

      payload: 'foo'
    })

    expect(isFSA(arrayInsert('myForm', 'myField', 0, 'foo'))).toBe(true)
  })
github redux-form / redux-form / src / __tests__ / actions.spec.js View on Github external
})

    expect(isFSA(arrayPush('myForm', 'myField', 'foo'))).toBe(true)

    expect(arrayPush('myForm', 'myField')).toEqual({
      type: ARRAY_PUSH,

      meta: {
        form: 'myForm',
        field: 'myField'
      },

      payload: undefined
    })

    expect(isFSA(arrayPush('myForm', 'myField'))).toBe(true)
  })
github DefinitelyTyped / DefinitelyTyped / types / flux-standard-action / flux-standard-action-tests.ts View on Github external
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 kpaxqin / redux-action-tools / test / createAction.specs.js View on Github external
const errAction = actionCreator(errObj);
      expect(errAction).to.deep.equal({
        type,
        payload: errObj,
        error: true
      });
      expect(isFSA(errAction)).to.be.true;

      const foobar = { foo: 'bar', cid: 5 };
      const noErrAction = actionCreator(foobar);
      expect(noErrAction).to.deep.equal({
        type,
        payload: foobar
      });
      expect(isFSA(noErrAction)).to.be.true;
    });
github FarmBot / Farmbot-Web-App / javascripts / redux / reducer.js View on Github external
export function reducer(state, action) {
  if (isFSA(action)) {
    console.log(action.type);
    console.dir(state);
    return (actions[action.type] || actions.DEFAULT)(state, action);
  } else {
    console.error("Action does not conform to 'flux-standard-action", action);
  }
  ;
}
;
github Gabri3l / redux-slim-async / src / index.js View on Github external
validateInput(action, options);

    if (!shouldCallAPI(getState())) return Promise.resolve(getState());

    const [pendingType, successType, errorType] = getActionTypes(
      typePrefix,
      types,
      options,
    );

    const pendingAction = isFSACompliant
      ? { payload, type: pendingType }
      : { ...payload, type: pendingType };

    if (isFSACompliant && !isFSA(pendingAction)) next(action);
    else dispatch(pendingAction);

    return callAPI()
      .then(response => {
        const formattedData = formatData(response);
        if (typeof formattedData !== 'object') {
          throw new Error(errorMessages.formatDataReturn);
        }

        const successAction = isFSACompliant
          ? {
              type: successType,
              payload: {
                ...payload,
                ...formattedData,
              },
github soliury / noder-react-native / src / store / promiseMiddleware.js View on Github external
return next => action => {
		if (!isFSA(action)) {
			return isPromise(action)
				? action.then(dispatch)
				: next(action)
		}
		const { meta = {}, payload } = action

		const id = _.uniqueId()

		if (isPromise(payload)) {
			dispatch({
				...action,
				payload: undefined,
				meta: {
					...meta,
					sequence: {
						type: 'start',
github dashed / redux-lens / src / index.js View on Github external
const isReduceInAction = (action) => {

    const reducer = lodashGetIn(action, path_to_redux_lens_reducer, NOT_SET);

    return isFSA(action) &&
        lodashGetIn(action, path_to_redux_lens_path, NOT_SET) !== NOT_SET &&
        reducer !== NOT_SET;
};

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