ktsn / sinai

Class based state management for Vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cross module dependencies

SachsKaylee opened this issue · comments

Hello there!

I've recently started using your library since I really love the type safety it brings. However I've hit a major roadblock. I have two modules (user session & current document="adventure" being edited) which some other modules depend on.

However, I cannot simply import my store in these modules without triggering a TypeScript compiler error due to it being a cyclic dependency: 'store' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.ts(7022)

index.ts:
image
[...snip...]
image

Room.ts:
[...snip...]
image
[...snip...]

If I remove the store import in the first line of the Room.ts screenshot everything compiles just fine.

I've tried some hacks such as accessing the private member store of the __proxy__ variable, but it always leads to the same error.

How would one introduce depenencies on other moduels with this library?

Thanks for your time!

Thanks for the quick reply! This looks promising.
Is there also a way to inject multiple modules?

https://github.com/ktsn/sinai/blob/master/src/core/base.ts#L31-L34

By the way, I don't recommend you to use Sinai if you are unsure how it work under the hood as this is experimental project. Take a look vuex-smart-module if you are looking for a production ready project.

Thanks, I'll take a more detailed look at vuex-smart-module. It mentions in its description that its somewhat based on Sinai.

How do the libraries compare? Are there some features that are exlusive to one library or the other? Or is vuex-smart-module just a "better and newer" version of sinai?

Thanks for your time investment in this issue, it's really appreciated! :)

Sinai is Vuex like store library developed from full scratch while view-smart-module is a Vuex wrapper.