पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv2.3.0

rx_notifier

मूल्य सूचक के विस्तार में फंक्शनल रिएक्टिव प्रोग्रामिंग (TFRP) को अदृश्य रूप से लागू करना

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
2.8 हज़ार
लाइक
82
Pub अंक
140

पैकेज इंस्टॉल करें

flutter pub add rx_notifier

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

RxNotifier एक Flutter/Dart पैकेज है जो ValueNotifier को स्पष्ट कार्यात्मक प्रतिक्रियाशील प्रोग्रामिंग (TFRP) के साथ विस्तारित करता है। यह फंक्शनल ऑपरेटर्स का उपयोग करके राज्य परिवर्तनों को संयोजित और रूपांतरित करने की अनुमति देकर प्रतिक्रियाशील राज्य प्रबंधन को सक्षम बनाता है, जबकि ValueNotifier की सरलता बनाए रखता है। पैकेज मौजूदा Flutter ऐप्स में आसानी से एकीकृत होता है, जो प्रतिक्रियाशील पैटर्न के साथ राज्य प्रबंधन के लिए हल्का विकल्प प्रदान करता है बिना बॉइलरप्लेट के। यह सभी प्रमुख प्लेटफॉर्म का समर्थन करता है और अपरिवर्तनीय अपडेट और स्ट्रीम-जैसे रूपांतरणों के माध्यम से साफ़, परीक्षण योग्य कोड को बढ़ावा देता है।

उपयोग

  • प्रतिक्रियाशील उपयोगकर्ता संवाद स्थिति अद्यतन
  • जटिल राज्य तर्क का संयोजन
  • बहुत सारे ValueNotifiers को बदलना
  • राज्य रूपांतरण को सरल बनाना
  • प्रतिक्रियाशील फॉर्म बनाना
  • असिंक्रोनस स्थिति का प्रबंधन

मुख्य विशेषताएँ

  • कार्यात्मक प्रतिक्रियाशील प्रोग्रामिंग
  • ट्रांसपेरेंट टीएफआरपी इंटीग्रेशन
  • अपरिवर्तनीय राज्य अद्यतन
  • स्ट्रीम-जैसे ऑपरेटर
  • न्यूनतम बॉयलरप्लेट
  • क्रॉस-प्लेटफ़ॉर्म समर्थन

इनके लिए उपयुक्त

  • प्रतिक्रियाशील अवस्था प्रबंधन की तलाश में विकासकर्ता
  • संयोज्य राज्य तर्क की आवश्यकता वाले ऐप्स
  • कार्यात्मक प्रोग्रामिंग के प्रति प्रसन्न टीमें
  • भारी अवस्था प्रबंधन से बचने वाले परियोजनाएँ
  • Flutter के शुरुआती लोग प्रतिक्रियाशील पैटर्न सीख रहे हैं
  • हल्के राज्य समाधान की आवश्यकता वाले ऐप्स

विचार योग्य बातें

  • कार्यात्मक प्रोग्रामिंग के अवधारणाओं की समझ की आवश्यकता है
  • शुरुआती लोगों के लिए सीखने का वक्र पेश कर सकता है
  • ValueNotifier पर आधारित प्रतिक्रियाशील पैटर्न तक सीमित
  • बहुत बड़े पैमाने पर राज्य प्रबंधन के लिए उपयुक्त नहीं
  • मध्यम जटिलता वाली अवस्था की आवश्यकताओं के लिए सबसे उपयुक्त
  • पूर्ण प्रतिक्रियाशील फ्रेमवर्क (जैसे RxDart) को प्रतिस्थापित नहीं करता है

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

rx_notifier

The ValueNotifier is a simple, native form of Flutter reactivity. This extension aims to transparently apply functional reactive programming (TFRP).

Implementing the Atomic State.

It is possible to implement Recoil Atoms pattern using RxNotifier. This pattern consists of the state being an object with its own reactivity.

atom

Motivation

Developers still have trouble understanding state management in Flutter. We had this conclusion after several research in the community fluttering and also in partner companies. Atomic State is a noob-friendly state management approuch at the same time that maintains a reliable structure thinking of scalability and maintenance.

More details, read this Medium article on the subject.

Rules

We must take into account some architectural limits to execute this Approach:

  1. All states must be an atom(RxNotifier instance).
  2. All actions must be an atom(RxNotifier instance).
  3. Business rules must be created in the Reducer and not in the Atom.

Layers

We will have 3 main layers, they are: Atoms, Reducers and Views;

atom

Note that the View (which is the presentation layer) does not know about the Reducer (which is the business rule execution layer). These two layers share atoms that in turn represent the state and the dispatch of state actions.

In Flutter these layers translate to Atom(RxNotifier), Reducer(RxReducer) and View(Widget):

atom

Atoms (RxNotifier)

Atom represent the reactive state of an application. Each atom has its own reactivity.

// atoms
final productsState = <Product>[].asRx();
final productTextFilterState = RxNotifier<String>('');

// computed
List<Product> get filteredProductsState {
     if(productTextFilterState.value.isEmpty()){
         return productsState.value;
     }

     return productsState.where(
         (p) => p.title.contains(productTextFilterState.value),
     );
}

// actions
final selectedProductState = RxNotifier<Product?>(null);
final fetchProductsState = RxNotifier(null);

Reducer (RxReducer)

In this architecture you are forced to split state management of business rules, which may seem strange at first when seen that we are always managing and reducing state in the same layer as BLoC and ChangeNotifier for example.
However, dividing state management and business rule execution will help us distribute multiple states to the same widget, and these multiple states will not need to be concatenated beforehand through a facade or proxy.

The layer responsible for making business decisions will be called Reducer:

class ProductReducer extends RxReducer {

    ProductReducer(){
        on(() => [fetchProductsState.action], _fetchProducts);
        on(() => [selectedProductState.value], _selectProduct);
    }

    void _fetchProducts(){
        ...
    }

    void _selectProduct(){
        ...
    }
}

Reducers can register methods/functions that listen to the reactivity of an Atom(RxNotifier).

View (Widget)

Any widget can listen to changes of one or many atoms, provided they have the RxRoot widget as their ancestor. For more details about RxRoot, Read the documentation.

The context.select() method is added via Extension to BuildContext and can be called on any type of Widget, StatefulWidget and StatelessWidget.


...
Widget build(BuildContext context){
     final products = context.select(
                 () => filteredProductsState.value
              );
     ...
}

Examples

Flutter projects using RxNotifier

Trivial Counter.

Shop Cart.

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 2 आइटम

  • collection^1.17.0
  • rx_notifier_annotation>=1.0.0 <2.0.0

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट

अभी कोई डेटा उपलब्ध नहीं है।