Wechaty Ducks Contrib
Image Source: TikZducks
See Ducks
npm install wechaty-ducks-contrib
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!'))
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())
getMO()
: Get Mobile Originated (MO) messages counter numbergetMT()
: Get Mobile Terminated (MT) messages counter number
Example:
Counter.selectors.getMO(store.getState().counter)()
// or using Ducksified API:
counterDuck.selectors.getMO()
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
Release v1.0 on Oct 29, 2021
- ES Modules support
Counter
Ducks released with example and unit tests.
Initial version.
- Requires Wechaty version
0.40
or above. - Requires WechatyRedux Plugin.
- API follows the Ducks proposal specification.
- Supports Ducksify for using with convenience.
- Code & Docs © 2020 Huan (李卓桓) <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons