GithubHelp home page GithubHelp logo

dacioromero / react-hook-wm Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 741 KB

React hooks for integrating with Web Monetization.

License: MIT License

TypeScript 95.89% JavaScript 4.11%
react react-hooks web-monetization

react-hook-wm's Introduction

React Hook WM

Hooks for integrating React with Web Monetization.

npm bundle size npm GitHub GitHub top language GitHub Workflow Status (branch) Codecov

Maintenance notice

As I am no longer an employee of Coil, this repo will likely no longer be maintained. If you'd like to maintain this repo please leave an issue.

Install

$ npm install react-hook-wm

or

$ yarn add react-hook-wm

Hooks

useStatus

Returns the current monetization state.

usePaymentPointer

Returns the latest paymentPointer/requestId received from any monetization event.

useRequestId

Returns the latest paymentPointer/requestId received from any monetization event.

useListener

Exposes a more React-ish way of interacting with monetization events through the following interface:

interface UseListenerOptions {
  onPending?: (event: MonetizationPendingEvent) => void
  onStart?: (event: MonetizationStartEvent) => void
  onProgress?: (event: MonetizationProgressEvent) => void
  onStop?: (event: MonetizationStopEvent) => void
}

useReducedListener

Attaches the provided reducer to events from useListener and returns the state produced. See the source for useCounter or the source for useHasPaid for examples.

useCounter

Returns the last assetCode (code) and the sum of the amounts (total) received from monetizationprogress events.

useCounterContext

Alternative to useCounter that requires a CounterProvider in one of its parent components. Allows for tracking prior to using the hook.

useHasPaid

Returns a Boolean indicating whether or not the payment pointer has been paid yet. Useful for determining requesting for pay-locked content is ready.

useHasPaidContext

Alternative to useHasPaid that requires a HasPaidProvider in one of its parent components. Allows for tracking prior to using the hook.

Components

CounterProvider

Provides useCounterContext's value. It's recommended that its children are memoized using React.memo.

HasPaidProvider

Provides useHasPaidContext's value. It's recommended that its children are memoized using React.memo.

Other Works

react-hook-wm's People

Contributors

dacioromero avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

react-hook-wm's Issues

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.