Coder Social home page Coder Social logo

vuexus's People

Contributors

spoki4 avatar

vuexus's Issues

Milestone vuex package 1.0.0

Установка:

npm install @vuexus/vue

Использование:

import Vuexus from '@vuexus/vue'

Vue.use(new Vuexus())

Описание модуля:

@Module
export class PageModule {
  data = []

  @SubModule
  subModule = new SubModuleClass()

  @Module(ParentModule)
  parentModule!: ParentModule

  get getMyData() {
     return this.data.map(...transform...)
  }

  @Mutation setData(data) {this.data = data}

  @Action async loadSomeData() {
     const response = await dataLoadFunc()
     this.setData(response)
     getStore(AuthModule).logout()
  }

  // Вызывается автоматически в соответствующем жизненом цикле
  @Hook.Created created(options) {
    // options = {params: {}, query: {}, cookies: {}}
    this.loadSomeData()
  }

  // Вызывается автоматически при изменении query параметров
  @Hook.QueryChanged onQueryUpdated(options) {
    // options = {params: {}, query: {}, cookies: {}}
  }
}

Использование в vue Parent:

<template>
   <div class="wrapper">
     <div v-for="item in store.getMyData">
     </div>     
     <child />
   </div>
<template>
<script>
export default {
  name: 'parent',
  stores: {
     store: PageModule
  }
}
</script>

Использование в vue Child:

<script>
export default {
  name: 'child',
  stores: {
     parentStore: PageModule // The same instance, gets from provide/inject
  }
}
</script>

Тесты:

const instance = createTestModule(ModuleClass)

instance.setData([1,2,3])

assert(instance.getData(), [1,2,3])

Reduce useless register/unregister store

store1 -> component1.beforeCreate -> store1.register -> store1.usages.push(component1)

store1 -> component2.beforeCreate -> store1.usages.push(component2)

component1.destoryed -> store1.usages.remove(component1)

component2.destoryed -> store1.usages.remove(component2) -> store1.usages.length === 0 -> store1.unregister

Уникальные namespaces

Варианты:

  1. Брать из названия класса, обязывать пользователя использовать уникальные названия классов.
  2. Брать название компонтента, где используется модуль, и делать это префиксом для модуля.
  3. babel-plugin -> hashOf(filepath, filename, line, column)

Terser class names collisions

When we use terser in project, that compress our classes and it can be has names as 'a' or 'b' or 'f' and more...

If our class names collide, we cannot register vuex module with same name.

It can be break production builds.

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.