Skip to content

viList in JS has undefined fields in handler #4368

@DushkaF

Description

@DushkaF

Describe the bug.

I’m trying to use vi_list in a JS app on Flipper Zero, but the valueUpdate event does not provide usable data.

According to documentation, the event should return fields like:

  • item_index
  • value_index

However, in practice both fields are undefined.

Reproduction

let eventLoop = require("event_loop");
let gui = require("gui");
let viListView = require("gui/vi_list");

let views = {
    config: viListView.makeWith({}, [
        { label: "Port", variants: ["usart", "lpuart"] },
        { label: "Baud", variants: ["57600", "115200", "921600"] },
    ]),
};

eventLoop.subscribe(views.config.valueUpdate, function (_sub, item) {
    // Trying to inspect event payload
    print("item_index:", item.item_index);
    print("value_index:", item.value_index);
});

eventLoop.subscribe(gui.viewDispatcher.navigation, function (_sub, _item, gui, views, eventLoop) {
    if(gui.viewDispatcher.currentView === views.config) {
        eventLoop.stop();
        return;
    }

    gui.viewDispatcher.switchTo(views.config);
}, gui, views, eventLoop);

gui.viewDispatcher.switchTo(views.config);
eventLoop.run();

Target

No response

Logs


Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions