0.1.5 • Published 5 years ago

redux-observable-rn-alert v0.1.5

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

redux-observable-rn-alert

npm version Build Status Coverage Status

This library offers a way to use Alert.alert() with a side-effect in a react-native app using redux & redux-observable.

Supported redux-observable versions

redux-observable versionSupporting redux-observable-rn-alert version
< 1.0.00.1.3
>= 1.0.0>= 0.1.4

Installation

yarn add redux-observable-rn-alert

or

npm i redux-observable-rn-alert --save

Setup

in the root epic, add alertEpic.

import { combineEpics } from 'redux-observable'
import { alertEpic } from 'redux-observable-rn-alert'

export const rootEpic = combineEpics(
  // ..
  alertEpic,
)

Usage

You can show an alert by calling the action. Also, you can pass actions that are called when buttons are pressed.

import { AlertActions } from 'redux-observable-rn-alert'

dispatch(
  AlertActions.alert({
    title: 'foo',
    message: 'bar',
    buttons: [
      {
        text: 'baz',
        onPressAction: { type: 'BAZ', payload: { qux: 'qux' } },
      },
    ],
    options: {
      // below are only for Android
      cancelable: true,
      onDismissAction: { type: 'QUX', payload: { qux: 'qux' } },
    },
    type: '',
  }),
)

Interface

Basically, the payload attributes of AlertActions.alert follow the attributes of Alert.alert(). below are the interface and differences from the attributes of Alert.alert().

NAMETYPEREQUIREDDIFFERENCE
titlestringYesNothing
messagestringNoNothing
buttonsArray<{ text?: string, onPressAction?: Action, style?: string }>NoonPressAction corresponds to onPress of Alert.alert()
options{ cancelable?: boolean, onDismissAction?: Action }NoonDismissAction corresponds to onDismiss of Alert.alert()
typestringNoNothing
0.1.5

5 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago