🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

rxjs-hooks-taro

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rxjs-hooks-taro

Taro hooks for RxJS

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

修改引用 @Taro/taro

本库 fork 自 rxjs-hooks 具体使用细节,请翻看 rxjs-hooks

Installation

Using npm:

$ npm i --save rxjs-hooks-taro

Or yarn:

$ yarn add rxjs-hooks-taro

Quick look

import Taro, { useState } from '@tarojs/taro'
import { View, Text, Button } from '@tarojs/components'
import { useObservable } from 'rxjs-hooks-taro'
import './index.less'
import { Subject, interval } from 'rxjs';
import { tap, map, withLatestFrom } from 'rxjs/operators';

interface IProps {}

function Index (props: IProps) {
  const [count$] = useState(new Subject<number>());
  const count = useObservable(()  => {
    return count$.pipe(
      tap(count => console.log('count ==>', count)),
      withLatestFrom(interval(1000)),
      map(([count, timeCount]) => count + timeCount)
    )
  }
  , 0);
  return (
    <View className='index'>
      <Text>count: {count}</Text>
      <Button onClick={() =>  {
        count$.next(count + 1)
      }}> + 1</Button>
      <Button> - 1</Button>
    </View>
  )
}

export default Index;

FAQs

Package last updated on 30 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts