How to mark pinia action private
Asked Answered
A

2

8

I have a pinia store action ("the Master Action") that mutates the store's state. This action is somewhat complicated, so i've broken it down into smaller "Child Actions" each of which mutates a small part of the store's state.

Question: How do I mark these Child Actions as private so that when the store is used in a component only the Master Action is available to be called?

Thanks

Anzac answered 29/4, 2023 at 20:8 Comment(0)
T
4

Full answer here.

TL;DR - You can write your "Child Actions" outside of the defineStore (in the same file or in a different file), and pass this as an argument.

Taco answered 7/10, 2023 at 12:15 Comment(0)
M
1

It's not the best and not the Pinia internal solution, but I do put an underscore (_) in the action names to indicate that they are private. I can't prevent store users from using it, but it worked for me in my scenario.

Mavismavra answered 18/11, 2023 at 0:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.