Skip to content

Commit

Permalink
Merge pull request writer#310 from mmikita95/chore-binding-syntax
Browse files Browse the repository at this point in the history
chore: binding syntax
  • Loading branch information
ramedina86 authored Mar 18, 2024
2 parents 94d33ea + 6bf2ab8 commit 602300c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/streamsync/ui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,16 @@ def _prepare_handlers(self, raw_handlers: Optional[dict]):
handlers[event] = handler
return handlers

def _prepare_binding(self, raw_binding):
# TODO
return raw_binding
def _prepare_binding(self, raw_binding: Optional[dict]):
if raw_binding is not None:
if len(raw_binding) == 1:
binding = {
"eventType": list(raw_binding.keys())[0],
"stateRef": list(raw_binding.values())[0]
}
return binding
elif len(raw_binding) != 0:
raise RuntimeError('Improper binding configuration')

def _prepare_value(self, value):
if isinstance(value, dict):
Expand All @@ -96,12 +103,12 @@ def _create_component(
kwargs.pop("parentId")

if "parentId" in kwargs:
parent_id = kwargs.pop("parentId")
parent_id: str = kwargs.pop("parentId")
else:
parent_id = "root" if not parent_container else parent_container.id

# Converting all passed content values to strings
raw_content = kwargs.pop("content", {})
raw_content: dict = kwargs.pop("content", {})
content = {key: self._prepare_value(value) for key, value in raw_content.items()}

position: Optional[int] = kwargs.pop("position", None)
Expand Down

0 comments on commit 602300c

Please sign in to comment.