
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
firex-store
Advanced tools
npm install --save firex-store
others comming soon
Return values or state values bounded to Firestore has docId
(documentId in Firestore) property.
This npm library methods use only one 'document' and 'collection' type in one store module
A store module cannot subscribe to more than one 'collection' and 'document'
If you want to subscribe again after unsubscribing 'collection', set the property of the store you want to subscribe to []
and then subscribe.
.....
firebase.initializeApp({
apiKey: [your firebase api key],
projectId: [your project id],
.....
})
export const firestore = firebase.firestore()
firestoreMutations
Ex. subscribe collection
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
.....
}
method: firestoreSubscribeActions
argments:
Ex. subscribe collection
// modules: comment
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
actions: {
...firestoreSubscribeActions({ ref: firestore.collection('/comments') })
}
.....
}
Ex. subscribe collection
<script>
import { actionTypes } from 'firex-store'
export default {
name: 'Comments',
created() {
this.$store.dispatch(`comment/${actionTypes.COLLECTION_SUBSCRIBE}`)
}
}
</script>
firestoreMutations
Ex. subscribe collection
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
.....
}
subscribeFirestore
in custom-actionssubscribeFirestore
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
actions: {
subscribe: ({ state, commit }) => {
subscribeFirestore({
state,
commit,
ref: firestore.collection('/comments'),
options
})
}
}
.....
}
Ex. unsubscribe collection
firestoreUnsubscribeActions
in actionsmethod: firestoreUnsubscribeActions
argments:
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
actions: {
...firestoreSubscribeActions({ ref: firestore.collection('/comments') }),
...firestoreUnsubscribeActions({ type: 'collection' })
}
.....
}
<script>
import { actionTypes } from 'firex-store'
export default {
name: 'Comments',
created() {
this.$store.dispatch(`comment/${actionTypes.COLLECTION_UNSUBSCRIBE}`)
}
}
</script>
method: unsubscribeFirestore
argments:
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
actions: {
subscribe: ({ state, commit }) => {
subscribeFirestore({
state,
commit,
ref: firestore.collection('/comments'),
options
})
},
unsubscribe: ({ state }) => {
unsubscribeFirestore({
state,
type: 'collection'
})
}
}
.....
}
method: findFirestore
argments:
EX. call in Store Action, to fetch collection
export default {
namespaced: true,
state: {},
getters: {},
mutations: {},
actions: {
fetchComments: async ({ commit }) => {
const ref = firestore.collection('/comments')
const result = await findFirestore({ ref })
commit(***, result)
}
}
}
Options
mapper:
errorHandler
console.error(error)
onCompleted
Ex.
const mapUser = (data) => ({
id: data.id
name: data.name
.....
})
const errorHandler = (error) => {
console.error(`[App Name]: ${error}`)
}
const onCompleted = () => {
console.log('completed!')
}
export default {
namespaced: true,
state: {
comments: [],
comment: null
},
mutations: {
...firestoreMutations({ statePropName: 'comments', type: 'collection' })
},
actions: {
subscribe: ({ state, commit }) => {
subscribeFirestore({
state,
commit,
ref: firestore.collection('/users').doc('userId'),
options: {
mapper: mapUser,
errorHandler,
onCompleted
}
})
}
}
.....
}
FAQs
Subscribe and write firestore data, easily
We found that firex-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.