wechaty-ducks-contrib
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

wechaty-ducks-contrib

NPM Version NPM Ducksify Extension ES Modules

Wechaty Ducks Contrib

Wechaty Ducks Redux

Image Source: TikZducks

Downloads TypeScript

What is Ducks

Ducksify Extension

See Ducks

Usage

Install

npm install wechaty-ducks-contrib

Using Ducks with Wechaty Redux

import {
  WechatyRedux,
  Duck as wechatyDuck,
}                     from 'wechaty-redux'
import { WechatyBuilder }     from 'wechaty'
import { Ducks }       from 'ducks'

const bot = WechatyBuilder.build({ puppet: 'wechaty-puppet-mock' })

const ducks       = new Ducks({ wechaty: wechatyDuck })
const store       = ducks.configureStore()
const wechatyDuck = ducks.ducksify('wechaty')

bot.use(WechatyRedux({ store }))

store.subscribe(() => console.info(store.getState()))
store.dispatch(wechatyDuck.actions.ding('redux!'))

Ducks References

1 Counter

import { Counter } from 'wechaty-ducks-contrib'
import { Ducks }       from 'ducks'

const ducks = new Ducks({ counter: Counter })
const counterDuck = ducks.ducksify('counter')

console.info(counterDuck.selectors.getMO())

1.1 selectors

  1. getMO(): Get Mobile Originated (MO) messages counter number
  2. getMT(): Get Mobile Terminated (MT) messages counter number

Example:

Counter.selectors.getMO(store.getState().counter)()
// or using Ducksified API:
counterDuck.selectors.getMO()

Example

There's a full example that demonstrate how to use the Wechaty Redux Ducks at examples/ducks.ts.

Use the following commands to run this example, and you can inspect the full source code of it to understand how to use Wechaty Redux and Wechaty Ducks.

git clone git@github.com:wechaty/wechaty-ducks-contrib.git
cd wechaty-ducks-contrib
npm install
npm start

History

master v1.0 (Sep 19, 2021)

Release v1.0 on Oct 29, 2021

  1. ES Modules support

v0.2 (Jun 5, 2020)

  1. Counter Ducks released with example and unit tests.

v0.0.1 (Jun 2, 2020)

Ducksify Extension

Initial version.

  1. Requires Wechaty version 0.40 or above.
  2. Requires WechatyRedux Plugin.
  3. API follows the Ducks proposal specification.
  4. Supports Ducksify for using with convenience.

Contributors

contributor contributor contributor contributor contributor contributor contributor contributor

Author

Huan LI (李卓桓) zixia@zixia.net

Profile of Huan LI (李卓桓) on StackOverflow

Copyright & License

  • Code & Docs © 2020 Huan (李卓桓) <zixia@zixia.net>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

Package Sidebar

Install

npm i wechaty-ducks-contrib

Weekly Downloads

2

Version

1.0.4

License

Apache-2.0

Unpacked Size

287 kB

Total Files

127

Last publish

Collaborators

  • zixia