Skip to content

Use composition instead of classes with Layout and LifeCycleHook  #412

Closed

Description

@rmorshea

This is similar to #324 but specifically focused on the Layout and LifeCycleHook since those will be the most complex to refactor. I'm not really sure what the interface would ultimately look like - whether there would still be a layout with render and dispatch methods, or if those would be functions accepting some sort of LayoutState instead. Maybe a bit like:

with layout_context(component) as layout:
    old_state, new_state = await render(layout)
    diff = compute_diff(old_state, new_state)
    await dispatch_event(layout)

You could take a similar approach to hooks as well, but just applying functions to objects containing state.

Activity

  1. rmorshea commented on Jul 16, 2021

    @rmorshea
    CollaboratorAuthor

    This is complete. The drastic changes suggested in the original comment aren't really productive because there's not much use in having access to the internal state of Layout. The ability to substitute Layout for some other implementation is what is most useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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