Drop

Drop

The Drop Module in the Flood toolkit aims to provide a consistent way to model data, query and update it, and be flexible to change the data source depending on the current environment. It offers a set of tools and components that simplify the process of defining, storing, querying, and updating data entities, making it easier to build robust and scalable applications.

Key Concepts

Drop introduces several key concepts that work together to provide a comprehensive data management solution:

  1. ValueObjects: Define the structure and format of your data, including validation rules and constraints.

  2. Entities: Represent the fundamental units of data storage, encapsulating ValueObjects with a unique identifier.

  3. Repositories: Determine where and how Entities are stored, with flexible options for different environments.

  4. Queries: Provide a powerful mechanism to retrieve and filter data from repositories.

  5. Security: Offer granular control over data access and operations.

  6. Auto-generated UI: Integrate with the Port Module to automatically generate user interfaces based on your data models.

  7. Hooks: Simplify data retrieval and binding in Flutter widgets, with automatic updates when data changes.

Implementations

Drop supports various repository implementations, including file-based storage, cloud-based storage, and environment-specific storage. However, the .cloud modifier on its own does not provide any implementation details. It requires repositoryImplementations to be passed into FloodCoreComponent to specify the exact implementation of the repositories to use in those environments.

For example, if you pass in FirebaseCloudRepositoryImplementation as one of the repositoryImplementations, it will make any .cloud repositories (or any .adapting repositories in a cloud environment) use the Firebase implementation. Similarly, you can provide implementations for other environments or storage mechanisms.

Here's an example of passing repository implementations to FloodCoreComponent:

example_core/lib/pond.dart
await corePondContext.register(FloodCoreComponent(
  repositoryImplementations: (corePondConext) => [
    FirebaseCloudRepositoryImplementation(),
  ],
));

By providing the appropriate repository implementations, you can easily switch between different storage mechanisms based on the environment or your application's requirements.

Use with Pond

To use Drop with Flood:

  1. Add the FloodCoreComponent to your CorePondContext and FloodAppComponent to your AppPondContext:
example_core/lib/pond.dart
await corePondContext.register(FloodCoreComponent(
  repositoryImplementations: [
    ...
  ],
));
example/lib/main.dart
await appPondContext.register(FloodAppComponent());
  1. Register your Repositories to the CorePondContext so that Flood knows where to find your data from your queries:
example_core/lib/pond.dart
await corePondContext.register(UserRepository());

By following these steps, Drop will be automatically added to your project, and you can start leveraging its features for data management and querying.

Debugging

Use the Debug Module to inspect your drop repositories and view the queries that were used to build a page.