monart 0.2.0
monart: ^0.2.0 copied to clipboard
Railway-Oriented Programming for Dart. Build composable service objects that return Result values — never throw — using Success, Failure, and andThen.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.2.0 - 2026-04-19 #
Changed #
andValueandandContextnow accept anyMatcherfrompackage:matcherin addition to plain values. Passing aMatcher(e.g.isA<UserSessionModel>(),containsPair(...)) evaluates it directly instead of wrapping it inequals. Plain values continue to work exactly as before.
0.1.1 - 2026-04-15 #
Fixed #
- Shortened
pubspec.yamldescription to comply with pub.dev length requirements. - Renamed
example/playground.darttoexample/example.dartso pub.dev recognises the example file.
0.1.0 - 2026-04-15 #
Added #
-
Result<Value>— sealed class representing the outcome of a service operation. Either aSuccess<Value>carrying a typed value, or aFailure<Value>carrying optional context. Results are never thrown; they are returned and composed. -
Success<Value>andFailure<Value>— concrete subtypes ofResult. Constructors accept a singleStringor aList<String>as outcome tags, normalised internally via_toOutcomes. -
Resultcombinators:andThen,orElse,map,when,onSuccess,onSuccessOf,onFailure,onFailureOf. -
FutureResult<Value>— typedef forFuture<Result<Value>>with a matchingFutureResultXextension that mirrors the full synchronous API for async pipelines. -
ServiceBase<Value>— abstract base class for service objects. Subclass and overriderun()to implement a business operation as a pipeline ofandThensteps. Built-in helpers:success,failure,check,tryRun. -
package:monart/monart_testing.dart— separate testing entry point (never bundled into production builds) exposing:haveSucceededWith/haveFailedWith—package:testmatchers with chainable.andValueand.andContextassertions.mockService<MockedService>— intercepts all.call()invocations of a service type and returns a fixedResultwithout executingrun(). No dependency injection required. RegistersclearServiceMocksas a per-test teardown automatically viaaddTearDown.clearServiceMocks— removes all active interceptors; useful for mid-test resets.MockService<Value>— aServiceBasesubclass for explicit injection scenarios, with.successand.failurenamed constructors.