Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cerebral-module-fuse

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cerebral-module-fuse

A cerebral module that adds fuzzy search to data in store

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

cerebral-module-fuse

A cerebral module that adds fuzzy search to data in the store.

Install

npm install cerebral-module-fuse

Usage

From your main.js

import controller from './controller'
import fuse form 'cerebral-module-fuse'

controller.modules({
  findUsers: fuse({
    statePath: ['users'],  // statePath should point to either an object or array in the store
    options: { keys: ['firstName', 'lastName'] } // options are passed on to fuse.js
  })
})

See fuse docs for more information about available options.

from your component.js

import React from 'react';
import { Decorator as Cerebral } from 'cerebral-view-react';
import fuse from 'cerebral-module-fuse/compute';

@Cerebral({
  users: fuse(['findUsers']) // where fuse is given the path to the module state
})
class App extends React.Component {
  render() {
    return (
      <ul>
        {this.props.users.map(user => (
          <li>{`${user.firstName} ${user.lastName}`}</li>
        ))}
      </ul>
    );
  }
}

to execute the search simply call the search signal and the view will automatically update

signals.findUsers.search({ query: 'John' })

you can also access the filtered data from an action via the provided services

export default myAction({ state, services: { findUsers } }) {
  const users = state.get(findUsers.fuse)
}

Contribute

Fork repo

  • npm install
  • npm start runs dev mode which watches for changes and auto lints, tests and builds
  • npm test runs the tests
  • npm run lint lints the code
  • npm run build compiles es6 to es5

Keywords

FAQs

Package last updated on 28 Jan 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc