blocx_core 0.8.4
blocx_core: ^0.8.4 copied to clipboard
Composable BLoC mixins and use-cases for lists & forms (Dart-only core).
Changelog #
0.8.4 #
Fixed #
-
Form submission validation
- Added full-form validation before submit hooks and use case execution.
- Blocked submit use case execution when validation errors exist.
- Blocked submission while required form info is loading.
- Blocked submission while unique-field validation is still running.
- Preserved
FormValidationModebehavior during submit, init, and field-update validation.
-
Form validation behavior
-
Updated
BlocxFormValidationMixinso:nonedisables validation.onSubmitvalidates the full form only on submit/full-validation requests.onUserInteractionvalidates changed fields while editing and the full form on submit.alwaysvalidates the full form on every update and submit.
-
Fixed field-level validation so validating one field no longer clears errors from unrelated fields.
-
-
Timed form errors
- Fixed timed field errors so timers dispatch clear events instead of reusing an old
Emitter. - Added timer cleanup when clearing errors.
- Added timer cleanup when
BlocxFormBloccloses.
- Fixed timed field errors so timers dispatch clear events instead of reusing an old
-
Unique-field validation
- Updated unique-field checks to use the new typed
BlocxUseCaseTask<Input, Output>API. - Awaited form updates after successful unique checks.
- Preserved stale-response protection through per-field request tokens.
- Forwarded use case stack traces to
handleError.
- Updated unique-field checks to use the new typed
-
Pagination
- Fixed
BlocxPage.hasNextto compare returned item count against the requestedlimit. - Replaced the old
loadCountfield withlimit.
- Fixed
Changed #
-
Use case task typing
-
Changed
BlocxUseCaseTaskfrom use-case-class/input typing to input/output typing:- Before:
BlocxUseCaseTask<UseCase, Input> - After:
BlocxUseCaseTask<Input, Output>
- Before:
-
Added
execute()toBlocxUseCaseTaskso callers no longer manually calltask.useCase.execute(task.inputBuilder()).
-
-
Paginated task typing
-
Changed
BlocxPaginatedUseCaseTaskto use input/output typing:BlocxPaginatedUseCaseTask<Input extends BlocxPaginatedInput, Output extends BlocxBaseEntity>
-
Added
execute(offset: ..., limit: ...)to centralize paginated task execution.
-
-
Paginated input naming
- Renamed
BlocxPaginationInputtoBlocxPaginatedInput. - Renamed the source file/export from
blocx_pagination_use_case.darttoblocx_paginated_use_case.dart. - Updated
BlocxSearchInputto extendBlocxPaginatedInput.
- Renamed
-
Form core mixin
- Replaced
BlocxFormDataMixinwithBlocxFormCoreMixin. - Removed the raw
FormSubmitTasktypedef. - Added stronger dartdocs for form initialization, update, validation, submission, payload handling, and submit hooks.
- Replaced
-
Form info fetching
- Updated
BlocxFormInfoFetcherMixin.requiredInitialInfoTasksto useMap<E, BlocxUseCaseTask<Object?, Object?>>. - Updated info-fetch execution to call
task.execute(). - Improved docs and immutable views for fetched info/loading state.
- Updated
-
Collection pagination mixins
- Updated collection core, infinite, refreshable, and searchable mixins to use
BlocxPaginatedUseCaseTask<Input, Output>. - Updated initial load, next-page load, refresh, search pagination, and search refresh to call
task.execute(...). - Improved error messages when required pagination/search tasks are missing.
- Cleared the existing list before applying initial-load and refresh results.
- Updated collection core, infinite, refreshable, and searchable mixins to use
-
Collection action mixins
-
Updated delete behavior to use task factories:
deleteItemTask(item)deleteMultipleItemsTask(items)
-
Added
performDeleteItem(item)fallback for custom delete implementations. -
Updated selection sync to use task factories:
selectItemTask(item)deselectItemTask(item)
-
Added rollback handling for failed remote selection and deselection sync.
-
Improved typed selection-change events and empty multi-select guards.
-
-
Public exports
- Exported
BlocxFormValidatorfromform_bloc.dart. - Exported additional non-string validator groups from
form_bloc.dart. - Updated
list_bloc.dartto exportblocx_paginated_use_case.dart.
- Exported
-
Documentation
- Expanded dartdocs across form core, form errors, validation, info fetching, unique-field validation, collection core, pagination, refresh, search, selection, deletion, page model, and use case task APIs.
Migration Guide #
Replace BlocxPaginationInput with BlocxPaginatedInput
// Before
class GetUsersInput extends BlocxPaginationInput {
const GetUsersInput({
required super.limit,
required super.offset,
});
}
// After
class GetUsersInput extends BlocxPaginatedInput {
const GetUsersInput({
required super.limit,
required super.offset,
});
}
Update paginated use case imports
// Before
import 'package:blocx_core/src/blocs/list/use_cases/blocx_pagination_use_case.dart';
// After
import 'package:blocx_core/src/blocs/list/use_cases/blocx_paginated_use_case.dart';
Prefer the public barrel when possible:
import 'package:blocx_core/list_bloc.dart';
Update normal use case tasks
// Before
BlocxUseCaseTask<CreateUserUseCase, CreateUserInput>(
useCase: createUserUseCase,
inputBuilder: () => CreateUserInput(...),
);
// After
BlocxUseCaseTask<CreateUserInput, UserEntity>(
useCase: createUserUseCase,
inputBuilder: () => CreateUserInput(...),
);
Update form submit tasks
@override
BlocxUseCaseTask<CreateAccountInput, AccountResponse> get submitUseCaseTask {
return BlocxUseCaseTask<CreateAccountInput, AccountResponse>(
useCase: createAccountUseCase,
inputBuilder: () {
return CreateAccountInput(
email: formData.email,
password: formData.password,
);
},
);
}
Update paginated collection tasks
@override
BlocxPaginatedUseCaseTask<GetUsersInput, UserEntity>? get paginationTask {
return BlocxPaginatedUseCaseTask<GetUsersInput, UserEntity>(
useCase: getUsersUseCase,
inputBuilder: (offset, limit) {
return GetUsersInput(
offset: offset,
limit: limit,
);
},
);
}
Update search tasks
@override
BlocxPaginatedUseCaseTask<BlocxSearchInput, UserEntity>? get searchUseCaseTask {
return BlocxPaginatedUseCaseTask<BlocxSearchInput, UserEntity>(
useCase: searchUsersUseCase,
inputBuilder: (offset, limit) {
return BlocxSearchInput(
searchText: searchText,
offset: offset,
limit: limit,
);
},
);
}
Update delete mixins
// Before
@override
BlocxBaseUseCase<UserEntity, bool>? get deleteItemUseCase {
return deleteUserUseCase;
}
// After
@override
BlocxUseCaseTask<DeleteUserInput, bool>? deleteItemTask(UserEntity item) {
return BlocxUseCaseTask<DeleteUserInput, bool>(
useCase: deleteUserUseCase,
inputBuilder: () {
return DeleteUserInput(id: item.id);
},
);
}
Update selection sync mixins
@override
BlocxUseCaseTask<SelectUserInput, bool>? selectItemTask(UserEntity item) {
return BlocxUseCaseTask<SelectUserInput, bool>(
useCase: selectUserUseCase,
inputBuilder: () {
return SelectUserInput(id: item.id);
},
);
}
@override
BlocxUseCaseTask<DeselectUserInput, bool>? deselectItemTask(UserEntity item) {
return BlocxUseCaseTask<DeselectUserInput, bool>(
useCase: deselectUserUseCase,
inputBuilder: () {
return DeselectUserInput(id: item.id);
},
);
}
0.8.3 #
Fixed #
- Improved package stability by fixing public exports, collection state copying, and initial search pagination behavior.
Changed #
- Updated documentation and migration guidance to reflect the current
BlocxCollectionBloc, task-based use case APIs, renamed infinite-list internals, and0.8.3usage.
0.8.2 #
- Updated CHANGELOG.md
0.8.1 #
Changed #
-
README terminology alignment
- Renamed documentation references from
BaseEntitytoBlocxBaseEntity. - Renamed documentation references from
BlocxPaginationUseCasetoBlocxPaginatedUseCase. - Updated examples and code snippets to use the current API naming.
- Simplified the collection mixins capability table and removed outdated
init*()references.
- Renamed documentation references from
-
BlocxPaginatedUseCaseTasktype constraints- Tightened generic bounds to require a
BlocxPaginatedUseCase<Input, dynamic>instead of a genericBlocxBaseUseCase, improving compile-time type safety and ensuring task/use-case compatibility.
- Tightened generic bounds to require a
0.8.0 #
Added #
-
BlocxPaginatedUseCaseTask— new task class that pairs a paginatedBlocxPaginatedUseCasewith aPaginationInputBuilder, receiving the currentlimitandoffsetat execution time. This is the standard task type forBlocxCollectionBloc.paginationTaskand supports per-operation overrides vialoadInitialPageTask. -
BaseBlocdocumentation — comprehensive dartdoc covering:- Internal
ScreenManagerCubitownership (consumers no longer need to construct or pass one). - Error handling via
handleErroranderrorDisplayPolicy(snackbar by default, overridable to full-page). - Navigation via
pop. - Custom error presentation via
BlocxErrorTranslatorregistered at app startup.
- Internal
-
InputBuildertype alias — replaces the inline function type inBlocxUseCaseTask, improving readability and reuse.
Changed #
-
Mixin export naming — list (
list_bloc.dart): removed_blocsegment from all collection mixin export paths for a flatter, consistent naming scheme:blocx_collection_bloc_infinite_mixin→blocx_collection_infinite_mixinblocx_collection_bloc_selectable_mixin→blocx_collection_selectable_mixinblocx_list_bloc_sync_stream_mixin→blocx_collection_sync_stream_mixinblocx_collection_bloc_deletable_mixin→blocx_collection_deletable_mixinblocx_collection_bloc_expandable_mixin→blocx_collection_expandable_mixinblocx_collection_bloc_highlightable_mixin→blocx_collection_highlightable_mixinblocx_collection_bloc_refreshable_mixin→blocx_collection_refreshable_mixinblocx_collection_bloc_scrollable_mixin→blocx_collection_scrollable_mixinblocx_collection_bloc_searchable_mixin→blocx_collection_searchable_mixin
-
Mixin export naming — form (
form_bloc.dart): standardised exports to theblocx_form_*prefix pattern:blocx_info_fetcher_form_mixin→blocx_form_info_fetcher_mixinblocx_stepped_form_mixin→blocx_form_stepped_mixin
-
Model export rename (
form_bloc.dart):base_form_entity.dart→blocx_base_form_entity.dart
-
BlocxUseCaseTaskdocs — condensed and clarified; class-level doc now explains lazyinputBuilderevaluation; inline field comments tightened.
Migration Guide #
List mixin imports
Update any direct imports of the renamed mixin files:
// Before
import 'package:blocx_core/src/blocs/list/mixins/blocx_collection_bloc_infinite_mixin.dart';
// After
import 'package:blocx_core/src/blocs/list/mixins/blocx_collection_infinite_mixin.dart';
The same pattern applies to all other renamed list mixins listed above.
Form mixin & model imports
// Before
import 'package:blocx_core/src/blocs/form/mixins/blocx_info_fetcher_form_mixin.dart';
import 'package:blocx_core/src/core/models/base_form_entity.dart';
// After
import 'package:blocx_core/src/blocs/form/mixins/blocx_form_info_fetcher_mixin.dart';
import 'package:blocx_core/src/core/models/blocx_base_form_entity.dart';
0.7.1 prior release #
See repository history for earlier entries.