0.9.20 • Published 4 years ago

vue-petit-store v0.9.20

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Install

yarn add vue-petit-store

API

mixin generator

nameargsdescription
replaceStateidsync vmid with URL using history.replaceState
pushStateidsync vmid with URL using history.pushState
sessionStorageidsync vmid with window.sessionStorage
localStorageidsync vmid with window.localStorage
cookieidsync vmid with document.cookie
firestore_docid, pathsync vmid with firestore document at vmpath
firestore_collectionid, path, chk, querysync vmid with firestore in query (indexed by doc id)
firestore_modelid, pathsync memory-orm with firestore document at vmpath
firestore_modelsid, path, chk, querysync memory-orm with firestore in query
vuex_readpath, keyssync vmid with vuex getter only work on update mutation
vuexpath, keyssync vmid with vuex work on update mutation
path_byid, id1, id2, ...(see examples)

examples

const { replaceState, pushState, sessionStorage, localStorage, cookie,
  firestore_models, firestore_model, firestore_collection, firestore_doc,
  vuex_read, vuex,
} = require("vue-petit-store")

example 1

module.exports = {
  mixins: [
    replaceState("idx"),
    path_by("idx", ["folder", "book", "part", "phase", "chat"]),
  ],
  data () {
    return {
      idx: "a-1"
    }
  }
}
helper methoddescription
vm.idx_type.by_urltype adjust
propertydescription
vm.idxVueRouter params.idx or query.idx or "a-1"
vm.idx_default"a-1"
vm.idx_avm.idx separeted by "-"
vm.folder_id"a"
vm.book_id"a-1"
vm.part_idundefined ( because part position 3 )
vm.phase_idundefined ( because part position 4 )
vm.chat_idundefined ( because part position 5 )
vm.folderrequire("memory-orm").Query.folders.find(vm.folder_id)
vm.bookrequire("memory-orm").Query.books.find(vm.book_id)
vm.partrequire("memory-orm").Query.parts.find(vm.part_id)
vm.phaserequire("memory-orm").Query.phases.find(vm.phase_id)
vm.chatrequire("memory-orm").Query.chats.find(vm.chat_id)

example 2

module.exports = {
  mixins: [
    localStorage("page_by"),
  ],
  data () {
    return {
      page_by: 30
    }
  }
}
helper methoddescription
vm.page_by_type.by_strtype adjust
propertydescription
vm.page_bywindow.localStorage.getItem("page_by") or 30
vm.page_by_default30

example 3

module.exports = {
  mixins: [
    vuex('firebase',['user', 'credential'])
  ],
}
propertydescription
vm.uservm.$store.state.firebase.user
vm.credentialvm.$store.state.firebase.credential
vm.user = { test: 'test' }vm.$store.commit("firebase/update", { user: { test: 'test' }})
vm.credential = { test: 'test' }vm.$store.commit("firebase/update", { credential: { test: 'test' }})

example 4

module.exports = {
  mixins: [
    firestore_doc("sign", function() { return this.user && `user/${ this.user.uid }` })
  ],
  data () {
    return {
      user: {
        uid: "TEST_UID",
      },
      sign: {
        sign: "",
        introduction: "",
      }
    }
  }
}
helper methoddescription
vm.sign_joinjoin with event handler
vm.sign_deldelete from snapshot
vm.sign_addset doc to snapshot
propertydescription
vm.signsync with sign_snap
vm.sign_snapfirestore doc at "user/TEST_UID"
vm.sign_default{ sign: '', introduction: '' }
vm.sign_path"user/TEST_UID"

example 5

module.exports = {
  mixins: [
    firestore_collection("markers",
      function () { return "marker" }
      function () { return this.uid && this.part_id }
      function (ref) { return ref.where('uid','==', this.uid ).where('part_id','==', this.part_id ) }
  ],
  data () {
    return {
      uid: "TEST_UID"
      part_id: "a-1-1"
      markers: {}
    }
  }
}
helper methoddescription
vm.marker_joinjoin with event handler
vm.markers_deldelete id from snapshot
vm.markers_addappend doc to snapshot
propertydescription
vm.markersfirestore sync here. vm.markersdoc_id = doc_data
vm.markers_snapfirestore collection at "marker"
vm.markers_defaultQuery
vm.markers_path"marker"
vm.markers_chktrue ("TEST_UID" && "a-1-1")
vm.markers_queryvm.markers_snap.where('uid','\=\=','TEST_UID').where('part_id','\=\=','a-1-1')

example 6

module.exports = {
  mixins: [
    firestore_models("markers",
      function () { return "marker" }
      function () { return this.uid && this.part_id }
      function (ref) { return ref.where('uid','==', this.uid ).where('part_id','==', this.part_id ) }
  ],
  data () {
    return {
      uid: "TEST_UID"
      part_id: "a-1-1"
    }
  }
  computed: {
    markers () {
      return this.uid && Query.markers.own(this.uid)
    }
  }
}
helper methoddescription
vm.marker_joinjoin with event handler
vm.markers_deldelete id from snapshot
vm.markers_addappend doc to snapshot
propertydescription
vm.markersQuery.markers.own("TEST_UID")
vm.markers_snapfirestore collection at "marker"
vm.markers_defaultQuery
vm.markers_path"marker"
vm.markers_chktrue ("TEST_UID" && "a-1-1")
vm.markers_queryvm.markers_snap.where('uid','\=\=','TEST_UID').where('part_id','\=\=','a-1-1')
0.9.20

4 years ago

0.9.19

4 years ago

0.9.17

4 years ago

0.9.18

4 years ago

0.9.16

4 years ago

0.9.14

4 years ago

0.9.15

4 years ago

0.9.13

4 years ago

0.9.12

4 years ago

0.9.11

4 years ago

0.9.10

4 years ago

0.9.9

4 years ago

0.9.8

4 years ago

0.9.7

4 years ago

0.9.6

4 years ago

0.9.5

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.37

5 years ago

0.8.36

5 years ago

0.8.35

5 years ago

0.8.34

5 years ago

0.8.33

5 years ago

0.8.32

5 years ago

0.8.31

5 years ago

0.8.30

5 years ago

0.8.29

5 years ago

0.8.28

5 years ago

0.8.27

5 years ago

0.8.26

5 years ago

0.8.25

5 years ago

0.8.24

5 years ago

0.8.23

5 years ago

0.8.22

5 years ago

0.8.21

5 years ago

0.8.20

5 years ago

0.8.19

5 years ago

0.8.18

5 years ago

0.8.17

5 years ago

0.8.15

5 years ago

0.8.14

5 years ago

0.8.13

5 years ago

0.8.12

5 years ago

0.8.11

5 years ago

0.8.10

5 years ago

0.8.9

5 years ago

0.8.8

5 years ago

0.8.7

5 years ago

0.8.6

5 years ago

0.8.5

5 years ago

0.8.4

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.7.16

5 years ago

0.7.15

5 years ago

0.7.14

5 years ago

0.7.13

5 years ago

0.7.12

5 years ago

0.7.11

5 years ago

0.7.10

5 years ago

0.7.9

5 years ago

0.7.8

5 years ago

0.7.7

5 years ago

0.7.6

5 years ago

0.7.5

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.24

5 years ago

0.6.23

5 years ago

0.6.22

5 years ago

0.6.21

5 years ago

0.6.20

5 years ago

0.6.19

5 years ago

0.6.18

5 years ago

0.6.16

5 years ago

0.6.15

5 years ago

0.6.14

5 years ago

0.6.13

5 years ago

0.6.12

5 years ago

0.6.11

5 years ago

0.6.10

5 years ago

0.6.9

5 years ago

0.6.8

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.0

5 years ago