Easy-peasy: how to create typed computed property with argument AND accessing global store state

Created on 15 Nov 2019  路  3Comments  路  Source: ctrlplusb/easy-peasy

Hello,

I have read the docs, but it doesn't mention this situation.

What is the right syntax for creating computed property with argument AND accessing global store state in typescript?

docs

Most helpful comment

There is no example for this scenario, only with argument or with state access.
I need both, but never mind, I think I figure it out:

    getModule: computed(
        [(state, storeState) => storeState.first.items,
            (state, storeState) => storeState.second.items
        ],
        (rt, rm) =>     
        (data: ListQuery) =>
        {
                }
    ),

All 3 comments

Hey @ebadta81

You should be able to find an example of this in the docs for the Computed type.

馃憤

There is no example for this scenario, only with argument or with state access.
I need both, but never mind, I think I figure it out:

    getModule: computed(
        [(state, storeState) => storeState.first.items,
            (state, storeState) => storeState.second.items
        ],
        (rt, rm) =>     
        (data: ListQuery) =>
        {
                }
    ),

Ah, sorry I misunderstood your request.

Was this page helpful?
0 / 5 - 0 ratings