Coder Social home page Coder Social logo

wechaty / ducks-contrib Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 1.0 413 KB

Wechaty Ducks Contrib

Home Page: https://paka.dev/npm/wechaty-ducks-contrib

License: Apache License 2.0

JavaScript 48.81% Shell 7.85% TypeScript 43.34%
wechaty redux ducks ducksify

ducks-contrib's Introduction

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 [email protected]: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 (李卓桓) [email protected]

Profile of Huan LI (李卓桓) on StackOverflow

Copyright & License

  • Code & Docs © 2020 Huan (李卓桓) <[email protected]>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.