IReferenceable

Interface with methods to set references for components that depend on other components.

Description

The IReferenceable interface allows you to set references for components that depend on other components.

Important points

  • If component requires explicit notification to unset references, it must also implement the IUnreferenceable interface.

Methods

SetReferences

Sets references to dependent components.

SetReferences(ctx context.Context, references IReferences)

  • ctx: context.Context - operation context.
  • references: IReferences - references to locate the component dependencies.

Examples

type MyController {
	_persistence IPersistence
}
func (mc* MyController) SetReferences(ctx context.Context, references IReferences) {
	res, descrErr = references.GetOneRequired(
		NewDescriptor("mygroup", "persistence", "*", "*", "1.0")
	)

    if descrErr != nil {
        panic(descrErr)
    }

    mc._persistence = res
}
...

See also