npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fetch-blob-redux-middleware

v0.0.4

Published

React-native-fetch-blob middleware for Redux.

Downloads

7

Readme

fetch-blob-redux-middleware

npm version npm monthly downloads

fetch-blob-redux-middleware redux middleware

npm install --save fetch-blob-redux-middleware

Usage

import fetchBlobMiddleware from 'fetch-blob-redux-middleware'

When I use'react-native-fetch-blob'in conjunction with'redux' when I want to cancel the request, the'action'becomes harder and harder to write and the code repeats more and more, so I wrote this middleware to solve these problems.

Using in combination with redux-actions

Because it supports FSA actions, you can use redux-fetch-blob-middleware in combination with redux-actions or create-action.

Example: Async action creators

This works just like in Flummox.

In action:

export const test = () => createAction("TEST",()=> 
	RNFetchBlob.fetch('GET', 'http://www.example.com/api/')
)

In component:

@connect(
    createSelector(
        [state=>state.test],
        (test)=>({test})
    ),
    dispatch=>({
        testAction:bindActionCreators(testAction,dispatch),
    })
)
class Test extends Component{

	constructor(props) {
   		super(props);
   		this.testFetchCancel = null;
   }
   
   componentWillUnmount(){
		//If the request has not come back, I can cancel it here.
		this.testFetchCancel && this.testFetchCancel.cancel();
   }

	onPress = () =>{
		let {
			props
		} = this;
		let {
			testAction
		} = props;
	 	this.testFetchCancel = testAction.test();
	}
	
	rebder(){
		return (
			<Button 
				onPress={this.onPress}
			>
				<Text>action<Text>
			</Button>
		)
	}
}

Unlike Flummox, it will not perform a dispatch at the beginning of the operation, only at the end. We're still looking into the best way to deal with optimistic updates. If you have a suggestion, let me know.