wechaty-ducks-contrib
Wechaty Ducks Contrib
Image Source: TikZducks
What is Ducks
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())
selectors
1.1 -
getMO()
: Get Mobile Originated (MO) messages counter number -
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
- ES Modules support
v0.2 (Jun 5, 2020)
-
Counter
Ducks released with example and unit tests.
v0.0.1 (Jun 2, 2020)
Initial version.
- Requires Wechaty version
0.40
or above. - Requires WechatyRedux Plugin.
- API follows the Ducks proposal specification.
- Supports Ducksify for using with convenience.
Contributors
Author
Copyright & License
- Code & Docs © 2020 Huan (李卓桓) <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons