npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

revux

v1.3.1

Published

Redux bindings for Vue.js

Downloads

8

Readme

revux

npm version Build Status Coverage Status

Inspired by Revue, use Redux with Vue.js seamlessly

We were not satisfied with the way the original Revue worked internally.

Basically, revux works by referencing your redux store on a Provider component. Every child component of the Provider will be able to access the store via a connect method: it aims to make the use of redux with vuejs a little more like react-redux

Installation

Install via NPM: npm i --save revux

API

connect connect([mapState], [mapDispatch])(Component)

mapState function is passed the state and the connected component's own props: mapState(state, [ownProps]) it should return a state object.

mapDispatch should be an object wrapping action creator functions - dispatch is bound automatically via redux's > bindActionCreators : mapDispatch = { foo: () => ({type: 'ACTION_CREATED'}) }

the result of mapState and mapDispatch will be accessible on your component's data properties

Getting started

For Vue-Router integration: check out the example folder

More details coming soon

store.js

Create your redux store:

import {createStore} from 'redux'
import reducer from './reducer'

const store = createStore(reducer)

export default store

index.js

import Vue from 'vue'
import revux from 'revux'
import main from './main.vue'

Vue.use(revux) // !!!

const app = new Vue({
  el: '#app',
  render: h => h(main)
})

main.vue

Use the Provider component from revux and bind your redux store. The store will be provided to all children components via vue's inject/provide mechanism.

<template>
    <Provider :store="store">
      <connectedComponent>
      </connectedComponent>
    </Provider>
</template>

<script>
  import store from './store'
  import connectedComponent from './connectedComponent.vue'

  export default {
    data () {
      return {
        store
      }
    },
    components: {
      connectedComponent
    }
  }
</script>

connectedComponent.vue

Import the connect method from revux to map state and actions to your instance's data. Here our state looks something like { status: 'foobar' }

<template>{{status}}</template>

<script>
  import { connect } from 'revux' // !!!
  import { createAction } from './actions'
  // createAction is an action creator of type () => ({type: 'ACTION_CREATED'})

  const component = {
    methods: {
      doMagic: function () {
        this.createAction()
      }
    }
  }

  const mapState = state => {
    const { status } = state
    return {
      status
    }
  })

  const mapDispatch = { createAction }

  export default connect(mapState, mapDispatch)(component)
</script>

NB:

You can also pass an object to mapState. Top-level object properties should be functions that get passed the state.

  const mapState = {
    status: state => state.status
  }

TODO:

  • [x] Remove redux dependency
  • [ ] Clean up dev environement (rollup, poi, karma etc..)