JSPM

  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q52673F
  • License Apache-2.0

Vuex module factory for Loopback 3

Package Exports

  • vuex-loopback

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vuex-loopback) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Vuex module factory for Loopback 3


Install

yarn add axios vuex-loopback

or

npm install axios vuex-loopback

Create vuex module

// Import axios and factory method.
import axios from 'axios';
import createModule from 'vuex-loopback';

// Create axios instance.
const client = axios.create({
  baseURL: 'https://some-domain.com/api/',
});

// Define collection name (as in loopback).
const articleName = 'Articles';

// Define collection model.
const articleModel = {
  id: '',
  name: '',
  body: '',
  categoryId: '',
};

// Define collection include to
// resolve relations automatically.
const articleInclude = [
  'category',
];

new Vuex.Store({
  modules: {
    // Define module name.
    articles: {
      // Will it be namespaced?
      namespaced: true,
      // Create module.
      ...createModule({
        client: client,
        model: articleModel,
        collection: articleName,
        state: {
          // Extend default state.
          include: articleInclude,
        },
      }),
    },
    // ...
  }
});

Todo

  • State factory.
  • Mutations factory.
  • Actions factory.
  • Getters factory.
  • Usage documentation.