• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ipfs-inactive/ipfs-redux-bundle: [DEPRECATED] Use ipfs-provider instead:

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

ipfs-inactive/ipfs-redux-bundle

开源软件地址:

https://github.com/ipfs-inactive/ipfs-redux-bundle

开源编程语言:

JavaScript 100.0%

开源软件介绍:

⛔️ DEPRECATED

This library is being deprecated and replaced with more flexible ipfs-provider.

This library will not be maintained.


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.

This module tries to connect to IPFS via multiple providers, in order:

  • ipfs-companion the IPFS instance from IPFS Companion directly.
  • window.ipfs in the current page via IPFS Companion.
  • js-ipfs-http-client with either a user provided apiAddress, the current origin, or the default /ip4/127.0.0.1/tcp/5001 address.
  • js-ipfs disabled by default. Pass tryJsIpfs: true, getJsIpfs: () => Promise to enable it. See Enable js-ipfs

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({
    // These are the defaults:
    tryCompanion: true,   // set false to bypass ipfs-companion verification
    tryWindow: true,      // set false to bypass window.ipfs verification
    tryApi: true,         // set false to bypass js-ipfs-http-client verification. Uses data from ipfsApi variable in localStorage
    tryJsIpfs: false,     // set true to attempt js-ipfs initialisation.
    getJsIpfs: null       // must be set to a js-ipfs instance if tryJsIpfs is true.
  })
  // ... 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
)

Enable js-ipfs

To enable js-ipfs, intialise the bundle with the following opts

  ipfsBundle({
    tryJsIpfs: true,
    getJsIpfs: () => import('ipfs')
  })
  • tryJsIpfs should be set to true
  • getJsIpfs should be a function that returns a promise that resolves with a JsIpfs constructor. This works well with dynamic import(), so you can lazily load js-ipfs when it is needed.

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.selectIpfsInvalidAddress()

  • boolean - Is the last API Address you tried to use invalid?

store.selectIpfsProvider()

  • string - Can be window.ipfs, js-ipfs-api or js-ipfs.

store.selectIpfsApiAddress()

  • string - The API address of the IPFS instance.

store.doInitIpfs()

store.doStopIpfs()

  • Stops the IPFS instance. It is only intended to use with js-ipfs.

store.doUpdateIpfsApiAddress(address)

  • Updates the API Address to address.

store.doDismissIpfsInvalidAddress()

  • Dismisses the invalid address error.

Contribute

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

License

MIT © Protocol Labs




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap