create-observable-thunk
TypeScript icon, indicating that this package has built-in type declarations

0.3.5 • Public • Published

Provides a H.O.F. that wraps any function returning an Rx.Observable in a thunk

Install

This has peer dependencies of rxjs@5.x.x, redux, and redux-thunk, which will have to be installed as well.

npm install --save create-observable-thunk

or

yarn add create-observable-thunk

Example

users-thunks.js

import { createObservableThunk } from "create-observable-thunk"
import { loadUser } "./users-api"
import { loadUsersRequest, loadUsersSuccess, loadUsersFailure } from "./users-actions"
 
export const loadUsers = createObservableThunk({
  method: api.loadUsers,
  before: loadUsersRequest,
  success: loadUsersSuccess,
  failure: loadUsersFailure,
})

components/UserContainer.jsx

import { connect } from "react-redux"
import { loadUsers } from "../users-thunks"
import { Users } from "./Users"
 
export const UsersContainer = connect(null, { loadUsers })(Users)

Package Sidebar

Install

npm i create-observable-thunk

Weekly Downloads

1

Version

0.3.5

License

MIT

Last publish

Collaborators

  • meduffy
  • ncphillips