Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related #34 #35
Motivation
variant
provides an API that allows us to render different components based on$store
value, but$store
value type is limited to string, and it's not convenient to use this API with different$store
types.Imagine we have
$user
store andisAdmin
boolean property and we want to render different components based on this property. With the current API, we need to write something like that:We may notice that this is inconvenient and the code looks strange. To solve this problem, we need to extend
variant
API so that developers can define the required component based on any type of $store value.New API usage example
When our
$store
contains a value with a type different from string, we can pass an array to cases property. Each case hasview
field andfilter
method that takes$store
value and returns a boolean value.variant
returned view component will render that component that first matchfilter
from up to down.Tasks:
Changelogs:
NonEmptyArray
type in types.ts