0.1.0 • Published 6 years ago

babel-plugin-s2s-d-action-creater v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

babel-plugin-s2s-d-action-constants

s2s plugin for d

Install

$ yarn add --dev babel-plugin-s2s-d-action-constants

Example

IN:

import { type UserRes } from '../../types/Api'
import * as constants from './constants'

export type FetchUser = {
  type: typeof constants.FETCH_USER,
  payload: string,
}

export type FetchUserSuccess = {
  type: typeof constants.FETCH_USER_SUCCESS,
  payload: UserRes,
}

export type Action = FetchUser | FetchUserSuccess

OUT:

// @flow
import { type UserRes } from '../../types/Api'
import * as constants from './constants'
import type { Action } from './types'

export const fetchUser = (payload: string): Action => {
  return {
    type: constants.FETCH_USER,
    payload,
  }
}

export const fetchUserSuccess = (payload: UserRes): Action => {
  return {
    type: constants.FETCH_USER_USER,
    payload,
  }
}

Usage

{
  ['s2s-d-action-creater']
}