# SimpleObjectFactory<T> constructor

SimpleObjectFactory<T>(

1. ObjectFactoryFunction<T> creator

)

Default implementation of the ObjectFactory interface that uses a creator function.

This class provides a simple, flexible way to create objects on demand using a provided creator function. It's the standard implementation used throughout the JetLeaf framework for object creation scenarios.

Key features:

- Simple delegation to a creator function
- Type-safe generic implementation
- Lightweight and efficient
- No internal state or caching
- Easy to compose and decorate

Usage scenarios:

- Pod instantiation in dependency injection
- Prototype scope object creation
- Factory method implementations
- Ad-hoc object creation requirements
- Decorator and wrapper patterns

Example usage:

    // Create a factory for UserService
    final userServiceFactory = _ObjectFactory<UserService>(
      () => UserService()..initialize(),
    );

    // Create instances as needed
    final userService1 = userServiceFactory.getObject();
    final userService2 = userServiceFactory.getObject();

    // Each call creates a new instance
    print(identical(userService1, userService2)); // false

creator: The function that creates new instances of type `T`. Must not be null and should handle its own error cases.

Example:

    // Simple constructor
    final factory = _ObjectFactory<UserService>(() => UserService());

    // Complex initialization
    final factory = _ObjectFactory<DatabaseConnection>(() {
      final connection = DatabaseConnection();
      connection.connect('jdbc:mysql://localhost:3306/mydb');
      connection.authenticate('user', 'password');
      return connection;
    });

    // With dependencies
    final factory = _ObjectFactory<OrderService>(() {
      final config = loadConfiguration();
      final repository = OrderRepository(config);
      return OrderService(repository);
    });

## Implementation

    SimpleObjectFactory(this.creator);