How to use the idom.Events function in idom

To help you get started, we’ve selected a few idom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rmorshea / idom / tests / test_core / test_element.py View on Github external
async def DivInDiv(self):
        inner_events = idom.Events()
        inner_events.on("Click", stop_propagation=True)

        async def outer_click_is_not_triggered():
            assert False

        inner = idom.html.div(
            {
                "style": {"height": "30px", "width": "30px", "backgroundColor": "blue"},
                "id": "inner",
            },
            event_handlers=inner_events,
        )
        outer = idom.html.div(
            {
                "style": {"height": "35px", "width": "35px", "backgroundColor": "red"},
                "onClick": outer_click_is_not_triggered,
github rmorshea / idom / tests / test_core / test_events.py View on Github external
def test_simple_events_object():
    events = idom.Events()

    @events.on("Click")
    async def click_handler():
        pass

    @events.on("keyPress")
    async def key_press_handler():
        pass

    assert isinstance(events["onClick"], EventHandler)
    assert isinstance(events["onKeyPress"], EventHandler)
    assert "onClick" in events
    assert "onKeyPress" in events
    assert len(events) == 2
github rmorshea / idom / tests / test_core / test_vdom.py View on Github external
import pytest

import idom
from idom.core.vdom import make_vdom_constructor, component


fake_events = idom.Events()


@fake_events.on("Click")
async def handler(event):
    pass


@pytest.mark.parametrize(
    "actual, expected",
    [
        (
            idom.vdom("div", [idom.vdom("div")]),
            {"tagName": "div", "children": [{"tagName": "div"}]},
        ),
        (
            idom.vdom("div", {"style": {"backgroundColor": "red"}}),
github rmorshea / idom / docs / source / widgets / snake.py View on Github external
return idom.html.div(
        {
            "style": {
                "height": f"{block_size * grid_size}px",
                "width": f"{block_size * grid_size}px",
            },
            "tabIndex": -1,
        },
        [
            idom.html.div(
                {"style": {"height": block_size}},
                [Block("white", block_size) for i in range(grid_size)],
            )
            for i in range(grid_size)
        ],
        event_handlers=idom.Events(),
    )