All Projects → mariotacke → Redux Electron Ipc

mariotacke / Redux Electron Ipc

Licence: mit
Redux Electron IPC Middleware

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Redux Electron Ipc

Iceoryx
iceoryx - true zero-copy inter-process-communication
Stars: ✭ 208 (+285.19%)
Mutual labels:  middleware, ipc
Sgf
This is a Smart Game Foundation (Not Framework)
Stars: ✭ 122 (+125.93%)
Mutual labels:  event, ipc
Ecal
eCAL - enhanced Communication Abstraction Layer
Stars: ✭ 292 (+440.74%)
Mutual labels:  middleware, ipc
Gear Lib
Gear-Lib, C library for IOT Embedded Multimedia and Network
Stars: ✭ 2,381 (+4309.26%)
Mutual labels:  event, ipc
Yarp
YARP - Yet Another Robot Platform
Stars: ✭ 358 (+562.96%)
Mutual labels:  middleware, ipc
Traefik2 Luascript
LuaScript middleware for Traefik v2
Stars: ✭ 44 (-18.52%)
Mutual labels:  middleware
Dawn
🌅 Dawn is a lightweight task management and build tool for front-end and nodejs.
Stars: ✭ 1,057 (+1857.41%)
Mutual labels:  middleware
Postix
Cashdesk system used at Chaos Communication Congress
Stars: ✭ 42 (-22.22%)
Mutual labels:  event
Znetcs.aspnetcore.authentication.basic
A simple basic authentication middleware.
Stars: ✭ 40 (-25.93%)
Mutual labels:  middleware
Express Fileupload
Simple express file upload middleware that wraps around busboy
Stars: ✭ 1,069 (+1879.63%)
Mutual labels:  middleware
Django Channels React Multiplayer
turn based strategy game using django channels, redux, and react hooks
Stars: ✭ 52 (-3.7%)
Mutual labels:  middleware
Guzzle Stopwatch Middleware
A Guzzle Stopwatch Middleware
Stars: ✭ 50 (-7.41%)
Mutual labels:  middleware
Graphql Factory
A toolkit for building GraphQL
Stars: ✭ 44 (-18.52%)
Mutual labels:  middleware
Redux Query
A library for managing network state in Redux
Stars: ✭ 1,055 (+1853.7%)
Mutual labels:  middleware
Codeigniter Middleware
Simplest yet powerful middleware library for codeigniter, can be used to make routes login only, apply roles and permission system, modify, intercept or preprocess requests.
Stars: ✭ 43 (-20.37%)
Mutual labels:  middleware
Microservices Using Rabbitmq
Python & Go microservices on Docker, using RabbitMQ for asynchronous IPC
Stars: ✭ 51 (-5.56%)
Mutual labels:  ipc
Wretch Middlewares
Collection of middlewares for the Wretch library. 🎁
Stars: ✭ 42 (-22.22%)
Mutual labels:  middleware
Authorization
PSR7 Middleware for authorization
Stars: ✭ 50 (-7.41%)
Mutual labels:  middleware
Proxykit
A toolkit to create code-first HTTP reverse proxies on ASP.NET Core
Stars: ✭ 1,063 (+1868.52%)
Mutual labels:  middleware
Egg Authz
egg-authz is an authorization middleware for Egg.js based on Casbin
Stars: ✭ 50 (-7.41%)
Mutual labels:  middleware

Redux Electron IPC Middleware

Build Status npm version Coverage Status GitHub license

A Redux middleware to reduce code around ipc calls in an Electron application. You can send and receive IPC events with a simple api.

Install

npm

npm install --save redux-electron-ipc

Usage

Check out the full demo application.

Window

import { applyMiddleware, createStore } from 'redux';
import createIpc, { send } from 'redux-electron-ipc';
import { pongActionCreator } from './actions';
import { exampleReducer } from './reducer';

// register an action creator to an ipc channel (key/channel, value/action creator)
const ipc = createIpc({
  'pong': pongActionCreator, // receive a message
  ...
});

const store = createStore(exampleReducer, applyMiddleware(ipc));

// send a message with arguments through the `send` utility function
store.dispatch(send('ping', 'redux', 'electron', 'ipc'));

Main

// your regular ipc setup
const electron = require('electron');
const { ipcMain } = electron;

...

// pong event with arguments back to caller
ipcMain.on('ping', (event, ...args) => {
  console.log('Ping', ...args);
  event.sender.send('pong', ...args);
});

API

redux-electron-ipc has a default constructor function for creating ipc middleware, and a named send utility function.

createIpc(events?: Object) => IpcMiddleware
send(channel: string, ...arg1?: Object, arg2?: Object, ..., argN?:Object) => Action

Events

Each key on the events object (default: {}) registers a single ipc channel response. The key designates the ipc channel; the value is a redux action creator to be dispatched.

{
  'ipc channel name': (event, ...args) => {
    return {
      type: 'YOUR_ACTION_TYPE',
      ... optional mapping of arguments ...
    }
  }
}

Examples

Sending an IPC event

Use the utility function send to issue an ipc message to the main thread. The method signature is the same as ipcRenderer's send.

Behind the scenes, the ipc middleware will trigger the ipc on the given channel with any number of arguments.

import { send } from 'redux-electron-ipc';

store.dispatch(send('ipc event channel', ...args));

Receiving an IPC event

To receive events, register a channel response when configuring the middleware.

const ipc = createIpc({
  'channel to listen to': () => {
    return {
      type: 'IPC_RESPONSE_ACTION',
      ... optional mapping of arguments ...
    }
  }
  ...
});

const store = createStore(exampleReducer, applyMiddleware(ipc));

What about redux-thunk?

redux-electron-ipc supports thunks out of the box as long as you install redux-thunk and apply the thunk middleware before the ipc middleware.

Example

const ipc = createIpc({
  'ipc channel name': () => dispatch =>
    dispatch({ type: 'DELAYED_ACTION_TYPE' })
});
const store = createStore(exampleReducer, applyMiddleware(thunk, ipc));

Questions

For any questions, please open an issue. Pull requests (with tests) are appreciated.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].