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
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.
wechaty-ducks-contrib
Wechaty Ducks Contrib
What is Ducks
See Ducks
Usage
Install
Using Ducks with Wechaty Redux
Ducks References
1 Counter
1.1
selectorsgetMO(): Get Mobile Originated (MO) messages counter numbergetMT(): Get Mobile Terminated (MT) messages counter numberExample:
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.
History
master v1.0 (Sep 19, 2021)
Release v1.0 on Oct 29, 2021
v0.2 (Jun 5, 2020)
CounterDucks released with example and unit tests.v0.0.1 (Jun 2, 2020)
Initial version.
0.40or above.Contributors
Author
Huan LI (李卓桓) zixia@zixia.net
Copyright & License