Match/Case issue

Hi,

I don’t know if it’s actually a bug or if I’m using it badly, but I have a problem with the Match/Case thing.

Here is my (simplified for a test case) code : MainView.js

var Observable = require('FuseJS/Observable');

var model = {
    fields: [{
        type: 'Text'
    }, {
        type: 'Image'
    }]
};

module.exports = {
    model: Observable(model)
};

MainView.ux

<App Theme="Basic" Background="#eeeeeeff">
    <JavaScript File="MainView.js"></JavaScript>
    <StackPanel>
        <Each Items="{model.fields}">
            <Panel>
                <Text Value="Item :" />
                <Match Value="{type}">
                    <Case Value="Text">
                    </Case>
                    <Case Value="Image">
                    </Case>
                </Match>
            </Panel>
        </Each>
    </StackPanel>
</App>

And it raises this error during the build : None of the global resources with alias 'Text' can be used here: The type must be compatible with 'object'. - [...]MainView.ux(8:1):E

Thanks for your help !

Try with this:

          <Case String="Text">
            <Text Value="Text" />
          </Case>
          <Case String="Image">
            <Text Value="Image" />
          </Case>

file

Many thanks, it works !

For Case you should use Bool, Number and String to check the value.

https://www.fusetools.com/learn/uno/api/fuse/reactive/case

OK thanks.

Maybe the Learn section deserves an update then : https://www.fusetools.com/learn/fuse#keyword-case :slight_smile:

EDIT : My bad, I was looking at the Localisation section.

Looks like the thing it says in the Learn is what I told you. You used Value in your case which is not working.

Uh my bad I was looking at the “Localization” section where “Value” is used…