# Signal Management

Actions that listen for signals are kept in SignalBus. When the relevant signal is fired, listening actions are triggered. In this way, there is no dependency between the place that fires the signal and the place that listens.

Sample uses:

```csharp
public class Installer : GameObjectInstaller
{
    public override void Install(DIContainer container)
    {
        container.Bind<SignalController>();
    }
}

public readonly struct FooSignal
{
    public readonly string Data;

    public FooSignal(data)
    {
        Data = data;
    }
}

public class SampleClass : MonoInjecter
{
    [Inject]
    private readonly SignalController _signalController;

    protected override void Awake()
    {
        base.Awake();

        SubscribeEvents();
    }

    private void SubscribeEvents()
    {
        _signalController.Subscribe<FooSignal>(OnFoo);
    }

    private void OnFoo(string signal)
    {
        Debug.Log($"Signal Received - string: {signal.Data}");
    }

    private void UnsubscribeEvents()
    {
        _signalController.Unsubscribe<UserDataReceivedSignal>(OnUserDataReceived);
    }

    private void OnDestroy()
    {
        UnsubscribeEvents();
    }
}

public class FooItem : MonoInjecter
{
    [Inject]
    private readonly SignalController _signalController;

    protected override void Awake()
    {
        base.Awake();

        _signalController.Fire(new FooSignal("Sample string from {gameObject.name]"));
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tariksavas.gitbook.io/tarject/docs/how-to-use/signal-management.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
