Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobaraujo7 committed Oct 27, 2023
1 parent bc6cdaa commit 37d49a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
# ASP - Atomic State Pattern

The [ValueNotifier](https://api.flutter.dev/flutter/foundation/ValueNotifier-class.html) is a simple, native form of Flutter reactivity.
This extension aims to transparently apply **functional reactive programming (TFRP)**.
ASP (Atomic State Pattern) offers a simplified and modularized approach to state management for Flutter.

## Install

```yaml
flutter pub add asp
```

## Understanding Extension.
## About

This extension adds a class **Atom** and a converter **ValueNotifier -> Atom** so that it can be observed transparently by the function **rxObserver()** and [Widget](https://api.flutter.dev/flutter/widgets/Widget-class.html) **RxBuilder**.
The ASP approach divides state management into "atoms" and "reducers". Atoms are the smallest units of state, while reducers listen for changes on specific atoms and react to them, potentially causing side effects or updating other atoms.

The **Atom** is directly an extension of [ValueListenable](https://api.flutter.dev/flutter/foundation/ValueListenable-class.html) then any object that implements it can be converted to **Atom**
## How to Use

The only difference from **Atom** to [ValueNotifier](https://api.flutter.dev/flutter/foundation/ValueNotifier-class.html) is the automatic signature function in Observers **rxObserver()** and **RxBuilder**, very similar to [MobX reactions](https://pub.dev/packages/mobx).

## Using

To start, instantiate an Atom.
An Atom is a unit of state that can be listened to for changes.

```dart
final counter = Atom<int>(0);
```

or convert a [ValueNotifier](https://api.flutter.dev/flutter/foundation/ValueNotifier-class.html) already existing using the **.asAtom()** method:

```dart
final counter = myValueNotifierCounter.asAtom();
```
> **IMPORTANT**: The **Atom()** method has been added to [ValueNotifier](https://api.flutter.dev/flutter/foundation/ValueNotifier-class.html) using [Extension Methods](https://dart.dev/guides/language/extension-methods).

And listen the changes using **rxObserver**:

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: asp
description: ASP (Atomic State Pattern) is a extension to ValueNotifier by transparently applying functional reactive programming (TFRP)
description: ASP (Atomic State Pattern) offers a simplified and modularized approach to state management for Flutter.
version: 1.2.0
homepage: https://github.com/Flutterando/asp

Expand Down

0 comments on commit 37d49a8

Please sign in to comment.