New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@acutejs/plugin-redux

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acutejs/plugin-redux

A plugin for Acute to use [Redux](https://redux.js.org/).

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

@acutejs/plugin-redux

A plugin for Acute to use Redux.

Usage

First, install the plugin and its peer-dependency, redux.

npm install @acutejs/plugin-redux redux

Then, use Redux’s helpers to create a store.

store.js

import { createStore, combineReducers } from 'redux';

const counter = (state = 0, action) => {
  switch (action.type) {
    case 'DECREMENT_COUNTER':
      return state - 1;
    case 'INCREMENT_COUNTER':
      return state + 1;
    default:
      return state;
  }
};

export default createStore(combineReducers({
  counter,
}));

Next, pass the plugin and a reference to the store to Acute’s createApp().

import redux from '@acutejs/plugin-redux';
import store from './store.js';

createApp({
  // ...
  plugins: [
    redux({
      store,
    }),
  ],
});

Finally, use the store’s methods to add interactivity to your Acute components.

import store from './store.js';

export default {
  events: {
    click() {
      store.dispatch({ type: 'INCREMENT_COUNTER' });
    }
  },
  render() {
    const { counter } = store.getState();
    const plural = counter === 1 ? 'time' : 'times';
    return `<button> You’ve clicked me ${message} ${plural} </button>`;
  },
};

FAQs

Package last updated on 12 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts