Code Monkey home page Code Monkey logo

ipfs-redux-bundle's Introduction

ipfs-redux-bundle

A redux bundle to create an IPFS instance and pass it as an extraArg to other store methods.

Build Status

See https://reduxbundler.com for more info on the wonders of redux bundles.

Uses window.ipfs-fallback to find the best IPFS instance available. This will window.ipfs if you have IPFS Companion installed, or a js-ipfs-api instance otherwise.

Usage

Add ipfs-redux-bundle to your store

bundles/index.js

import { composeBundles } from 'redux-bundler'
import ipfsBundle from 'ipfs-redux-bundle'
// ... import other bundles

export default composeBundles(
  ipfsBundle()
  // ... add bundles here
)

In your app, you can now connect up the doInitIpfs function. Here we init IPFS when our root component mounts:

App.js

import React, { Component } from 'react'
import { connect } from 'redux-bundler-react'

export class App extends Component {
  componentDidMount () {
    this.props.doInitIpfs()
  }
  render () {
    // ipfs-css powered gorgeous ui here.
  }
}

export default connect(
  'doInitIpfs',
  App
)

API

Adds the following methods to the redux store

store.selectIpfsReady()

  • boolean - Is the IPFS instance ready to use yet?

store.selectIpfsInitFailed()

  • boolean - Did the IPFS instance fail to start?

store.selectIpfsIdentity()

  • Object - The last resolved value of ipfs.id()

store.selectIpfsApiAddress()

  • string - The API address of the IPFS instance.

store.doInitIpfs()

  • Create a new IPFS instance. This will window.ipfs if you have IPFS Companion installed, or a js-ipfs-api instance otherwise.

store.doUpdateIpfsAPIAddress(address)

  • Updates the API Address to address.

Contribute

Feel free to dive in! Open an issue or submit PRs.

License

MIT © Protocol Labs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.