From 423fdb06ec23e0f47fbda6e1d703e12caaa5ebb4 Mon Sep 17 00:00:00 2001 From: PatricNox Date: Tue, 22 Sep 2020 09:51:15 +0200 Subject: [PATCH] Update README.md regarding getters and params Adds a section regarding the possibility of using a getter with a parameter. Code and suggestion given through https://github.com/championswimmer/vuex-module-decorators/issues/40 --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 684cf25..18fcd16 100644 --- a/README.md +++ b/README.md @@ -193,6 +193,18 @@ const module = { } ``` +## Parameters inside a getter + +In order to handle parameters, simply return a function like so: + +``` +get getUser() { + return function (id: number) { + return this.users.filter(user => user.id === id)[0]; + } +} +``` + ### Putting into the store Use the modules just like you would earlier