Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tim-smart/elemental
A toolkit for writing software in dart. Effect-system, dependency management and more!
https://github.com/tim-smart/elemental
dart effect-system flutter state-management
Last synced: about 2 months ago
JSON representation
A toolkit for writing software in dart. Effect-system, dependency management and more!
- Host: GitHub
- URL: https://github.com/tim-smart/elemental
- Owner: tim-smart
- Created: 2022-09-13T01:19:14.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-31T02:46:38.000Z (about 2 months ago)
- Last Synced: 2024-07-31T08:42:01.511Z (about 2 months ago)
- Topics: dart, effect-system, flutter, state-management
- Language: Dart
- Homepage:
- Size: 646 KB
- Stars: 21
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
A toolkit for writing software in dartIncludes:
- `ZIO` a building block for writing effectful programs. Explore the full API: https://pub.dev/documentation/elemental/latest/elemental/ZIO-class.html
- `Layer` for composing dependencies
- `nucleus`, a simple state and dependency management tool. See more here: [https://pub.dev/packages/nucleus](https://pub.dev/packages/nucleus)
- Thanks to the `fpdart` package [https://pub.dev/packages/fpdart](https://pub.dev/packages/fpdart):
- `Option`
- `Either`
- Immutable data structures, thanks to [https://pub.dev/packages/fast_immutable_collections](https://pub.dev/packages/fast_immutable_collections)## Usage
The `ZIO` type represents an synchronous or asynchronous operation.
- The `R` generic is for representing the requirements / environment
- The `E` generic is for representing errors
- The `A` generic is for the success typeThere are a handful of helpful methods to ease composition!
```dart
import 'package:elemental/elemental.dart';ZIO greeting(String name) => ZIO(() => "Hello $name!")
// Note `ZIO` can be shortened to `IO`.
// Here we create a simple wrapper around `print`
IO log(String message) => IO(() => print(message)).asUnit;// And compose them together!
greeting.tap(log).run();
```It is worth noting that the above will run synchronously. Only when you start
using `Future`'s in your program, will things run asynchronously.### Layers
A quick intro to services and layers can be found in `example/`.