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

पैकेज विवरणv0.4.0

redux_thunk

एक Redux.dart मिडलवेयर जो आपको एक्शन के रूप में एसिंक काम करने वाले फ़ंक्शन को डिस्पैच करने की अनुमति देता है।

AndroidiOSWebmacOSWindowsLinux
30-दिन डाउनलोड
27 हज़ार
लाइक
66
Pub अंक
160

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

flutter pub add redux_thunk

पैकेज अवलोकन

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

redux_thunk एक मध्यवर्ती सॉफ्टवेयर है जो Redux.dart के लिए है, जो कार्रवाई के रूप में फ़ंक्शन (थंक्स) को डिस्पैच करने की अनुमति देता है, जिससे एपीआई कॉल या देरी वाले कार्य जैसे असिंक्रोनस ऑपरेशन को रेड्यूक्स स्टेट मैनेजमेंट फ्लो में संभाला जा सकता है। यह एक्शन क्रिएटर में सीधे एसिंक्रोनस लॉजिक को समर्थन देकर रेड्यूक्स के एक्शन डिस्पैच मैकेनिज्म को बढ़ाता है, जिससे कोड की संगठन और रखरखाव में सुधार होता है। यह पैकेज Flutter ऐप्स के साथ बिल्कुल एकीकृत होता है जो Redux.dart का उपयोग करते हैं, जिससे ओवरसाइड इफेक्ट्स वाले जटिल स्टेट ट्रांजिशन को प्रबंधित करना आसान हो जाता है। यह डेटा फीचर, प्रमाणीकरण प्रवाह या बैकग्राउंड प्रोसेसिंग की आवश्यकता वाले ऐप्स में विशेष रूप से उपयोगी है।

उपयोग

  • एसिंक एपीआई कॉल्स का हैंडलिंग
  • प्रमाणीकरण व्यवस्थापन कार्यप्रवाह
  • स्थगित या शर्तपूर्ण क्रियाओं को निष्पादित करना
  • जटिल राज्य अद्यतन को सरल बनाना
  • Redux में साइड इफेक्ट्स का कार्यान्वयन करना
  • कई एसिंक ऑपरेशन को समन्वयित करना

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

  • असिंक कार्य निर्माता समर्थन करता है
  • Redux.dart के साथ एकीकरण
  • कार्यों के निर्गमन की अनुमति देता है
  • साफ़ तरीके से प्रभावों का प्रबंधन करता है
  • असिंक्रोनस लॉजिक के लिए बॉयलरप्लेट कम करता है
  • सभी फ्लटर प्लेटफॉर्म पर काम करता है

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

  • Redux.dart का उपयोग करने वाले Flutter ऐप्स
  • एसिंक राज्य तर्क का प्रबंधन करने वाले विकासकर्मी
  • संरचित साइड इफेक्ट हैंडलिंग की आवश्यकता वाली टीमें
  • आवेदन जिनमें आईपीए के लगातार अंतरक्रिया होती है
  • पूर्वानुमान योग्य अवस्था परिवर्तन की आवश्यकता वाले प्रोजेक्ट
  • जटिल राज्य प्रबंधन के स्थितियाँ

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

  • Redux.dart सेटअप की आवश्यकता है
  • सरल ऐप्स के लिए जटिलता जोड़ता है
  • अतिरिक्त त्रुटि संहार की आवश्यकता हो सकती है
  • सरल राज्य समाधान का उपयोग करने पर आवश्यक नहीं है
  • बड़े पैमाने वाले एप्लिकेशन के लिए सबसे उपयुक्त
  • अन्य राज्य प्रबंधन उपकरणों के स्थान पर बजाय इसका पूरक है

मूल README

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

redux_thunk

Build Status codecov

Redux provides a simple way to update a your application's State in response to synchronous Actions. However, it lacks tools to handle asynchronous code. This is where Thunks come in.

The thunkMiddleware intercepts and calls ThunkActions, which is simply a fancy name for any function that takes 1 argument: a Redux Store. This allows you to dispatch functions (aka ThunkActions) to your Store that can perform asynchronous work, then dispatch actions using the Store after the work is complete.

The dispatched ThunkActions will be swallowed, meaning they will not go through the rest of your middleware to the Store's Reducer.

Example
// First, create a quick reducer
State reducer(String state, action) =>
    action is String ? action : state;

// Next, apply the `thunkMiddleware` to the Store
final store = new Store<String>(
  reducer,
  middleware: [thunkMiddleware],
);

// Create a `ThunkAction`, which is any function that accepts the 
// Store as it's only argument. Our function (aka ThunkAction) will
// simply send an action after 1 second.  This is just an example, 
// but  in real life, you could make a call to an HTTP service or 
// database instead!
void action(Store<String> store) async {
  final searchResults = await new Future.delayed(
    new Duration(seconds: 1),
    () => "Search Results",
  );

  store.dispatch(searchResults);
}

// You can also use a function with some parameters to create a thunk, 
// and then use it like so: store.dispatch(waitAndDispatch(3));
ThunkAction<String> waitAndDispatch(int secondsToWait) {
  return (Store<String> store) async {
    final searchResults = await new Future.delayed(
      new Duration(seconds: secondsToWait),
      () => "Search Results",
    );

    store.dispatch(searchResults);
  };
}


Credits

All the ideas in this lib are shamelessly stolen from the original redux-thunk library and simply adapted to Dart.

श्रेणियाँ

निर्भरताएँ

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

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

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