Skip to content

How to use multiple services and events providers ? #191

@labordep

Description

@labordep

Discussed in https://github.com/OpenSmock/Molecule/discussions/162

Originally posted by labordep June 9, 2023
The problem appears when we are using multiple Components with the same contract definition (static), during the execution we are subscribe to multiple components and we are interesseted of uses same services contract from mutiple Component with different name.

For events, actually we are receiving all events but without the way to know the name of the emitter. A solution is to add the name of the emitter directly in the arguments of the events but this is not compatible with Component principles (do not modify used contract). For services, a solution is to create a services method manually which invoke the services from the targeted Component name, but this is uggly.

May be some solutions :

  • Services : Return a proxy when a service is called self myUsedComponentServices componentNamed: #componentB myServices
  • Events : get the name of the provider from the stack, as an example using thisContext to get the name of the emitter

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions