How to use spunky - 10 common examples

To help you get started, we’ve selected a few spunky 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 nos / client / src / renderer / settings / actions / feeActions.js View on Github external
import BigNumber from 'bignumber.js';
import { createActions } from 'spunky';

import { getStorage, setStorage } from 'shared/lib/storage';

const DEFAULT_FEE = '0.00000000';

export const ID = 'fee';

// Setters
export const setFee = createActions(ID, (fee) => async () => {
  const value = new BigNumber(fee);

  if (value.isNaN()) {
    throw new Error(`Invalid fee value: "${fee}"`);
  }

  const formattedValue = value.toFixed(8);

  await setStorage(ID, formattedValue);
  return formattedValue;
});

// Getters
export default createActions(ID, () => async () => {
  const fee = await getStorage(ID);
  return typeof fee === 'string' ? fee : DEFAULT_FEE;
github CityOfZion / neon-wallet / app / actions / claimsActions.js View on Github external
// @flow
import { api, u } from 'neon-js'
import { createActions } from 'spunky'

type Props = {
  net: string,
  address: string
}

export const ID = 'CLAIMS'

export default createActions(ID, ({ net, address }: Props = {}) => async (state: Object): Promise => {
  const total = await api.getMaxClaimAmountFrom({ net, address }, api.neoscan)
  return { total: total instanceof u.Fixed8 ? total.toString() : null }
})
github CityOfZion / neon-wallet / app / actions / ledgerActions.js View on Github external
// @flow
import { createActions } from 'spunky'

import { getDeviceInfo, getPublicKey } from '../ledger/ledgerNanoS'

export const ID = 'LEDGER'

export default createActions(ID, () => async (state: Object) => {
  const deviceInfo = await getDeviceInfo()
  const publicKey = await getPublicKey()

  return { publicKey, deviceInfo }
})
github nos / client / src / login / components / LoginFormLedger / index.js View on Github external
const mapLedgerActionsToProps = (actions) => ({
  poll: () => actions.call()
});

const mapLedgerDataToProps = (data) => {
  const { deviceInfo, publicKey } = data || {};
  return { deviceInfo, publicKey };
};

const mapLedgerErrorToProps = (error) => ({
  deviceError: error
});

export default compose(
  withActions(ledgerActions, mapLedgerActionsToProps),
  withData(ledgerActions, mapLedgerDataToProps),
  withError(ledgerActions, mapLedgerErrorToProps),

  // redirect on login
  withRouter,
  withLogin((state, { history }) => history.push('/browser'))
)(LoginFormLedger);
github CityOfZion / neon-wallet / app / hocs / withProgressChange.js View on Github external
const passDownProps = omit(this.props, DATA_PROP, PROGRESS_PROP)
        return 
      }

      getCallbackState = props => ({
        data: props[DATA_PROP],
        error: props[ERROR_PROP],
      })

      getCallbackProps = props =>
        omit(props, DATA_PROP, ERROR_PROP, PROGRESS_PROP)
    }

    return compose(
      withProgress(actions, { propName: PROGRESS_PROP }),
      withData(actions, mapDataToProps),
      withError(actions, mapErrorToProps),
    )(WrappedComponent)
  }
}
github nos / client / src / renderer / browser / hocs / withClean.js View on Github external
return (Component) => {
    class WithCleanComponent extends React.PureComponent {
      componentWillUnmount() {
        this.props[propName]();
      }

      render() {
        return ;
      }
    }

    return withActions(actions, mapActionsToProps)(WithCleanComponent);
  };
}
github nos / client / src / renderer / shared / hocs / withProgressChange.js View on Github external
const passDownProps = omit(this.props, DATA_PROP, PROGRESS_PROP);
        return ;
      }

      getCallbackState = (props) => {
        return { data: props[DATA_PROP], error: props[ERROR_PROP] };
      }

      getCallbackProps = (props) => {
        return omit(props, DATA_PROP, ERROR_PROP, PROGRESS_PROP);
      }
    }

    return compose(
      withProgress(actions, { propName: PROGRESS_PROP }),
      withData(actions, mapDataToProps),
      withError(actions, mapErrorToProps)
    )(WrappedComponent);
  };
}
github CityOfZion / neon-wallet / app / hocs / withProgressPanel.js View on Github external
export default function withProgressPanel(
  actions,
  { title, strategy = recentlyCompletedStrategy, ...options } = {},
) {
  const Loading = withProps({ title })(LoadingPanel)
  const Failed = withProps(props => ({ title, onRetry: props.onRetry }))(
    FailedPanel,
  )

  return compose(
    withActions(actions, mapActionsToProps),
    withProgressComponents(
      actions,
      {
        [LOADING]: Loading,
        [FAILED]: Failed,
      },
      {
        strategy,
        ...options,
      },
    ),
  )
}
github CityOfZion / neon-wallet / app / hocs / withBalancesData.js View on Github external
export default function withBalancesData(mapBalancesDataToProps: Function) {
  return withData(balancesActions, mapBalancesDataToProps)
}
github nos / client / src / renderer / register / components / Register / index.js View on Github external
import { compose } from 'recompose';
import { withData } from 'spunky';

import withUnmountReset from 'shared/hocs/withUnmountReset';

import Register from './Register';
import createAccountActions from '../../actions/createAccountActions';

const mapAccountDataToProps = (account) => ({ account });

export default compose(
  withUnmountReset(createAccountActions),
  withData(createAccountActions, mapAccountDataToProps)
)(Register);

spunky

Lifecycle management for react-redux

MIT
Latest version published 7 years ago

Package Health Score

36 / 100
Full package analysis

Similar packages