Skip to content

Commit a3e2a6f

Browse files
Merge pull request #571 from dallinbjohnson/makeServiceActions-options-args
Pass options to makeActions in make-service-module to have access to …
2 parents 9a83f0e + ee99945 commit a3e2a6f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/service-module/make-service-module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function makeServiceModule(
2323
state: makeDefaultState(options),
2424
getters: makeGetters(),
2525
mutations: makeMutations(),
26-
actions: makeActions(service)
26+
actions: makeActions({service, options})
2727
}
2828
const fromOptions = _pick(options, [
2929
'state',

src/service-module/service-module.actions.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ eslint
66
import fastCopy from 'fast-copy'
77
import { getId } from '../utils'
88
import { Service } from '@feathersjs/feathers'
9+
import { MakeServicePluginOptions } from './types'
910

10-
export default function makeServiceActions(service: Service<any>) {
11+
interface serviceAndOptions {
12+
service: Service<any>
13+
options: MakeServicePluginOptions
14+
}
15+
16+
export default function makeServiceActions({service, options}: serviceAndOptions) {
1117
const serviceActions = {
1218
find({ commit, dispatch }, params) {
1319
params = params || {}
@@ -322,9 +328,9 @@ export default function makeServiceActions(service: Service<any>) {
322328
commit('removeItems', toRemove) // commit removal
323329
}
324330

325-
if (service.FeathersVuexModel) {
331+
if (options.Model) {
326332
toAdd.forEach((item, index) => {
327-
toAdd[index] = new service.FeathersVuexModel(item, { commit: false })
333+
toAdd[index] = new options.Model(item, { commit: false })
328334
})
329335
}
330336

0 commit comments

Comments
 (0)