Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] what are makeCons and makeElmishCons? #14

Open
OnurGumus opened this issue Sep 3, 2022 · 1 comment
Open

[Question] what are makeCons and makeElmishCons? #14

OnurGumus opened this issue Sep 3, 2022 · 1 comment

Comments

@OnurGumus
Copy link

Hi, I peeked the source code but still I am a bit confused. Could you explain what are makeCons and makElmishCons?

@alfonsogarciacaro
Copy link
Member

Yes, sorry, this should be either private or have a better explanation. It took also me a while to remember why I wrote those functions 😅

The cons(tructor) is just a function that returns a store. The idea is that Store could be a generic value. Why? Because at the beginning Fable.Store was written for interop with Svelte and Svelte has its own stores. This way Fable Svelte apps can write Elmish apps that could be sent to Svelte as a normal Svelte store.

However, when we wanted to extend Fable.Store to other apps we wanted to make IStore compatible with IObservable instead so we could take advantage of Observable pipelines (though unfortunately I haven't seen many examples of this) so we implemented our own store interface. This is way when you call Store.makeElmish an IStore is created by default, but if you use SvelteStore.makeElmish an Svelte store is used instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants