Giter VIP home page Giter VIP logo

vuex-asr's Introduction

Vuex-ASR - Automated Store Resolution for Vue

Example TodoMVC app

For a quick overview of a full implementation of vuex-asr, take a look at the codesandbox todo-mvc-example or visit the git-repository.

install

You can install the package via NPM:

npm install vuex-asr

setup

In your (typically) main.js:

import Vue from "vue";
import App from "./App.vue";
import { Store } from "./vuex/store";
import VuexASR from "vuex-asr";

Vue.use(VuexASR);

new Vue({
  render: h => h(App),
  store: Store
}).$mount("#app");

and you're ready to use vuex-asr.

what is vuex-asr?

Vuex-asr removes the necessity to describe your vuex store bindings in the component's script. With vuex-asr you're able to bind state, getters, mutations and actions from the component's attributes\directives:

  • asr-bind-state
  • asr-bind-getters
  • asr-bind-mutations
  • asr-bind-actions

The plugin automatically resolves bindings and is able to map them from the component's attributes, allowing your component's code to become generic and independent from the Vuex store ๐Ÿ˜Ž.

vuex-asr provides full interactivity with vuex.

codesandbox examples

The step by step guide contains examples with codesandboxes so you could start right away with exploring the features, with no setup required.

tl;dr

generic components able to be stateful

With vuex-asr you could start developing your codebase with generic components (no bindings described in the component code) and hook them up to the vuex ecosystem, by the attribute of the component.

simple example

Assume you have a vuex store:

const Store = new Vuex.Store({
  state: {
    message: "This is a message in the Root of VUEX",
  }
});

With asr-bind-state you could bind the state item message like this:

<message-component asr-bind-state="message"/>

If you have your state item in a namespace you could bind it like this:

<message-component asr-bind-state="User/Settings/message"/>

If you have to alias your state item to match components name convention:

<message-component asr-bind-state="User/Settings/notifyMessage AS message"/>

This will bind the the state item notifyMessage, living in the namespace User/Settings, AS message to the <message-component>.

// MessageComponent.vue

<template>    
    <div class="some-markup">
        {{ message }}
    </div>
</template>

about reactivity

If User/Settings/notifyMessage updates in the store, the message in <message-component> will update too.

a more complex implementation

We could also use it to provide more complex components with store bindings:

    <some-component
      asr-bind-state="
        message, 
        USER/userObject AS user,
        PHOTOS/recentPhotos
        PHOTOS/likedPhotos"
      asr-bind-getters="
        PHOTOS/recentPhotos
        PHOTOS/likedPhotos"
      asr-bind-mutations="
        USER/setMessageUser
        PHOTOS/addNewPhoto"
      asr-bind-actions="
        PHOTOS/fetchNewPhotos"
    ></some-component>

In this case we bind state, getters, mutations and actions items to <some-component>.

Follow the step by step manual to get started it contains sandboxes, so no setup is required to try out all of the examples and fiddle around.

vuex-asr's People

Contributors

jorislive avatar vuex-asr avatar

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.