Skip to content

Greeter example in README is unclear #112

@AldeRoberge

Description

@AldeRoberge

I find the current “Greeter” example a bit unintuitive for users who are new to the dependency injection pattern. While it’s great for people already familiar with DI, it doesn’t provide much guidance for Unity developers who are used to MonoBehaviour singletons and want to learn how to migrate their code to Reflex.

It would be really helpful to include an additional example or section in the README that:

  • Starts with a typical Unity singleton (e.g. GameManager.Instance pattern).
  • Then demonstrates how to convert it to Reflex DI, step by step.

🧩 Example Idea

For instance, start with:

public class GameManager : MonoBehaviour
{
    public static GameManager Instance;
    void Awake() => Instance = this;
    public void StartGame() => Debug.Log("Game Started");
}

Then show how to rewrite it using Reflex:

public class GameManager
{
    public void StartGame() => Debug.Log("Game Started");
}

public class GameInstaller : MonoBehaviour, IInstaller
{
    public void InstallBindings(ContainerBuilder builder)
    {
        builder.AddSingleton<GameManager>();
    }
}

And how to inject it:

public class GameStarter : MonoBehaviour
{
    [Inject] private GameManager _gameManager;
    void Start() => _gameManager.StartGame();
}

This kind of example would make it much easier for newcomers to understand how Reflex replaces common Unity patterns and what the benefits are.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions