Skip to content

Commit

Permalink
V0.4.1 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMaglione authored Feb 25, 2023
2 parents 899b76a + dd62057 commit e892c8d
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 79 deletions.
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
# v0.4.1 - 25 February 2023
- New methods for `Option` type (thanks to [tim-smart](https://github.com/tim-smart) 🎉)
- `flatMapNullable`
- `flatMapThrowable`
```dart
final option = Option.of(10);
option.flatMapNullable((a) => a + 1); /// 👈 `Some(11)`
option.flatMapThrowable((a) => a + 1); /// 👈 `Some(11)`
option.flatMapNullable<int>((a) => null); /// 👈 `None()`
option.flatMapThrowable<int>((a) => throw "fail"); /// 👈 `None()`
```

- Improved support `fromJson` for `Option` type (thanks [again] to [tim-smart](https://github.com/tim-smart) 🎉)
- Allow for decoding of **non-primitive types** (with custom `fromJson` constructors)
```dart
/// `fromJson` on `DateTime` with `Option` type
final now = DateTime.now();
Option<DateTime>.fromJson(now.toIso8601String(), (a) => DateTime.parse(a as String)); /// 👈 `Some(now)`
Option<DateTime>.fromJson("fail", (a) => DateTime.parse(a as String)); /// 👈 `None()`
```

- New extension methods for `Map` (thanks [once again] to [tim-smart](https://github.com/tim-smart) 🎉)
- `extract`
- `extractMap`
```dart
final map = <String, dynamic>{'a': 1, 'b': 2, 'c': 3, 'd': 4};
map.extract<int>('b'); /// 👈 `Some(2)`
map.extract<String>('b'); /// 👈 `None()`, not of type `String` ⚠️
final map = <String, dynamic>{'a': 1};
map.extractMap('a'); /// 👈 `None()`, not a `Map`
final map = <String, dynamic>{'a': {'b': 2} };
map.extractMap('a'); /// 👈 `Some({'b': 2})`
```

- `Option.of` and `Option.none` factories `const` (thanks to [f-person](https://github.com/f-person) 🎉)

> **Note**: People who have the [prefer_const_constructors](https://dart.dev/tools/linter-rules#prefer_const_constructors) lint enabled will notice a warning to use `const` 🤝
- New [`managing_imports`](./example/managing_imports) example (thanks to [RandalSchwartz](https://github.com/RandalSchwartz) 🎉)
- Updated [README](./README.md) introduction

# v0.4.0 - 16 December 2022
- Added extension methods to work with nullable types (`T?`)
- From `T?` to `fpdart`'s types
Expand Down
34 changes: 27 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# `Fpdart`
<h3 align="center">
<a href="https://github.com/SandroMaglione/fpdart">
<img src="./example/screenshots/screenshot_fpdart.png" width="500" />
</a>
</h3>


<p>
<p align="center">
<strong>Functional programming in Dart and Flutter</strong>
</p>

<p align="center">
All the main functional programming types and patterns <strong>fully documented</strong>, tested, and with examples
</p>


<p align="center">
<a href="https://github.com/SandroMaglione/fpdart">
<img src="https://img.shields.io/github/stars/SandroMaglione/fpdart?logo=github" />
</a>
Expand All @@ -15,10 +29,7 @@
</a>
</p>


Functional programming in Dart and Flutter.

All the main functional programming types and patterns **fully documented**, tested, and with examples.
## Introduction

> **Fpdart is fully documented. You do not need to have any previous experience with functional programming to start using `fpdart`. Give it a try!**
Expand All @@ -28,10 +39,15 @@ Fpdart is inspired by [fp-ts](https://gcanti.github.io/fp-ts/), [cats](https://t
***

- [Introduction](#introduction)
- [📖 Learn `functional programming` and `fpdart`](#-learn-functional-programming-and-fpdart)
- [👨‍💻 Blog posts and tutorials](#-blog-posts-and-tutorials)
- [💻 Installation](#-installation)
- [✨ Examples](#-examples)
- [Pokeapi](#pokeapi)
- [Open Meteo API](#open-meteo-api)
- [Read/Write local file](#readwrite-local-file)
- [Manage imports](#manage-imports)
- [Option](#option)
- [Either](#either)
- [IO](#io)
Expand Down Expand Up @@ -84,7 +100,7 @@ Check out also this series of articles about functional programming with `fpdart
```yaml
# pubspec.yaml
dependencies:
fpdart: ^0.4.0 # Check out the latest version
fpdart: ^0.4.1 # Check out the latest version
```
## ✨ Examples
Expand All @@ -106,6 +122,9 @@ A 2 parts series explains step by step the Open Meteo API code:
### [Read/Write local file](./example/read_write_file/)
Example of how to read and write a local file using functional programming.

### [Manage imports](./example/managing_imports)
Using `fpdart` with other libraries and noticing naming conflicts? Learn how to rename the classes that conflict with other SDK or third-party packages.

### [Option](./lib/src/option.dart)
Used when a return value can be missing.
> For example, when parsing a `String` to `int`, since not all `String`
Expand Down Expand Up @@ -336,6 +355,7 @@ In general, **any contribution or feedback is welcome** (and encouraged!).

## 📃 Versioning

- v0.4.1 - 25 February 2023
- **v0.4.0** - 16 December 2022
- **v0.3.0** - 11 October 2022
- **v0.2.0** - 16 July 2022
Expand Down
2 changes: 1 addition & 1 deletion example/json_serializable/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ packages:
path: "../.."
relative: true
source: path
version: "0.4.0"
version: "0.4.1"
frontend_server_client:
dependency: transitive
description:
Expand Down
Loading

0 comments on commit e892c8d

Please sign in to comment.