# chain<R> method

Future<ObjectFactory<R>> chain<R>(

1. ObjectFactory<R> nextFactory(
   1. T
   )

)

Creates a new ObjectFactory that uses this factory's output as input to another factory.

This method enables chaining of factories for more complex creation logic.

`nextFactory`: A function that takes a `T` instance and returns an ObjectFactory<R> Returns a new ObjectFactory that produces `R` instances

Example:

    final configFactory = ObjectFactory<Config>(() => Config.load());

    // Chain with a service factory that needs config
    final serviceFactory = configFactory.chain<Service>((config) =>
      ObjectFactory<Service>(() => Service(config))
    );

    final service = serviceFactory.getObject(); // Service with configured dependencies

## Implementation

    Future<ObjectFactory<R>> chain<R>(ObjectFactory<R> Function(T) nextFactory) async {
      final create = () async {
        final firstResult = await get();
        final next = nextFactory(firstResult.getValue());
        return next;
      };

      final result = await create();
      return SimpleObjectFactory<R>(([args]) => result.get(args));
    }