How to use flux-standard-action - 10 common examples

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 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<TextPayload> = {
    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<TextPayload> = {
    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 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);
  }
  ;
}
;

flux-standard-action

A human-friendly standard for Flux action objects

MIT
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Popular flux-standard-action functions