Fluent-State lacks a way to intercept and modify state transitions before they occur. Adding fluentState.use((prev, next, transition) => {...}) allows developers to implement logging, security checks, or validation before proceeding.
Example Usage:
fluentState.use((prev, next, transition) => {
console.log(`Checking transition: ${prev} → ${next}`);
if (next === 'mainApp' && !userHasAccess()) {
console.log("Access Denied!");
return; // Prevents transition
}
transition(); // Proceed to next state
});
Acceptance Criteria (AC):
- Middleware should run before transitioning to the next state.
- If
transition() is not called, the transition should be blocked.
- Multiple middleware functions should execute in order.
- Existing unit tests pass.
- Add new unit tests for all AC.
- Test cases should include middleware execution and blocking transitions.
Fluent-State lacks a way to intercept and modify state transitions before they occur. Adding
fluentState.use((prev, next, transition) => {...})allows developers to implement logging, security checks, or validation before proceeding.Example Usage:
Acceptance Criteria (AC):
transition()is not called, the transition should be blocked.