Skip to content

How to properly bind to ViewModel data that is avaialbe after Awake? #38

Description

@robertverdes

This seems like a a great library, and I might be severely missing the point, but I don't see a way out of the box to support binding to ViewModels that have their data populated after Awake (since initializiation for binders seems to happen on Awake).
e.g.

  • when the ViewModel is created at runtime, and then initialized (since Unity doesn't allow initializing a GameObject before Awake except if it's disabled, and that's an ugly flow for prefabs)
  • or even, using IViewModelProvider to have POCO VMs, as you suggested in previous issue replies: how can GetViewModel return a valid non-MonoBehaviour instance that's somehow injected into the MonoBehaviour (ony way I see is you'd have to call some static singleton-ish provider class from within the method for it to happen before Awake, and I'd like to be able to stick with a DI flow)

Adding [DefaultExecutionOrder(100)] to AbstractMemeberBinding fixes it for VMs already in the scene at lauch, but it doesn't work for those created at runtime.

Any insights welcome! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions