You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In (VideOMDbSample)[https://github.com/AngelMunoz/VideOMDbSample], there's an example that uses a match expression that doesn't compile:
match currentPage.Value with| Pages.Movie id -> Pages.Movie.View id
| Pages.Landing -> Pages.Landing.View()| Pages.Search -> Pages.Search.View()| Pages.Movie id -> Pages.Movie.View id
Like if/else expressions, every branch has to be of the "same type". This is propably something I have to explain and document, because it's not intuitive what "same type" means: It is the type Vide<'value, 'state, 'context> where value is the component's actual return value (usually unit ), but state is something that is propably not the same type when partial views differ.
Here's the comment of @AngelMunoz on his expectations:
Yes I expected that to work, even for the if/else case as it is a fairly common use case IMO, something that comes to my mind is “Routing” routers often return a different component based on what was resolved by the router, partial views are also something that comes to mind, e.g. user is authenticated show this, not authenticated show that.
how can we continue in these kinds of scenarios or how is the user expected to reduce dynamic views?
Since it's not possible to define custom handling for if/else or match expressions in the context of CEs, this issue must be documented in a very prominent way, or it could be handled with "conditional" and "witch" library functions that have to be used instead of if/else or match.
I came up with an implementation of switch / case that allows for
cases that show only when there's no previous case that was shown,
cases that always show (when their condition is met; independent of previous cases),
default case
specify if a case shall preserve it's state or reset it on show
Example:
vide {let!(viewNr :int)= chooseView
// There are 3 views. The 2nd view's state is cleared on every show.// All other view retain their state.
switch (fun x -> x = viewNr)|> case 0 componentWithBooleanState
|> caseForget 1 componentWithIntState
|> case 2 componentWithStringState
|> caseDefault (div {"Nothing to show - this is the default case."})}
In (VideOMDbSample)[https://github.com/AngelMunoz/VideOMDbSample], there's an example that uses a match expression that doesn't compile:
Like if/else expressions, every branch has to be of the "same type". This is propably something I have to explain and document, because it's not intuitive what "same type" means: It is the type Vide<'value, 'state, 'context> where value is the component's actual return value (usually unit ), but state is something that is propably not the same type when partial views differ.
There's an explanation that might help: https://vide-dev.io/docs/vide.fable/conditions/
Here's the comment of @AngelMunoz on his expectations:
Since it's not possible to define custom handling for if/else or match expressions in the context of CEs, this issue must be documented in a very prominent way, or it could be handled with "conditional" and "witch" library functions that have to be used instead of if/else or match.
...and additionally:
The text was updated successfully, but these errors were encountered: