HydratedTriple은 앱 재시작 시 스토어 상태를 자동으로 지속하고 복원함으로써 상태 관리를 단순화하는 Flutter/Dart 패키지입니다. Triple 패턴 위에 구축되어 있으며, Riverpod 또는 Provider와 원활하게 통합되어 사용자 설정, 로그인 상태, 폼 입력과 같은 데이터를 수동 직렬화 없이 유지할 수 있게 해줍니다. 믹스인은 로컬 저장소(예: SharedPreferences)에 상태를 저장하고 앱을 시작할 때 다시 불러오는 작업을 처리하여 반복 코드를 줄이고 사용자 경험을 향상시킵니다. 최소한의 설정으로 신뢰성 있는 상태 지속이 필요한 앱에 적합합니다.
사용 사례
사용자 선호 사항 유지
재시작 후 로그인 상태 복원
양식 데이터를 일시적으로 저장합니다
세션 간에 앱 설정 유지
오프라인 우선 시나리오 처리
주요 기능
자동 상태 유지
Riverpod/Provider와의 원활한 통합
여러 플랫폼을 지원합니다
최소한의 보일러플레이트
내장 시리얼라이제이션
크로스 플랫폼 호환성
적합한 대상
지속 상태가 필요한 앱
트리플 패턴을 사용하는 개발자
오프라인 기능을 갖춘 프로젝트
개발자 생산성을 우선시하는 팀
최소 코드로 상태 관리
고려 사항
상태 객체의 올바른 직렬화가 필요합니다
앱 시작 시간이 약간 증가할 수 있습니다
크거나 자주 변경되는 상태에 적합하지 않음
사용자 정의 로직이 추가되지 않는 한 간단한 상태 구조에만 제한됨
기본 상태 관리 솔루션에 의존함
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Triple - Segmented State Pattern
Welcome to Triple!
Design Pattern for State Management.
Triple is a nickname to SSP (Segmented State Standard).
Some packages were created to make it easier for developers to start using the standard. We'll call it an extension.
Segmented State Pattern (SSP)
When we talk about a single flow state, we end up solving architecture problems early, as we will have only one data flow for each state.
In addition to the maintainability and to the ease of use architecture, we also have the possibility of increasing this flow with other standards such as the Observer, which gives reactivity to the component when it is modified, and Memento, which makes it possible to revert or redo this state.
A beautiful example of a pattern with a single flow is BLoC, giving reactivity to a state allowing all transformations in that flow. This (although complicated for some), consolidates very well in the architecture of a project, even the limits of this practice are beneficial for not allowing the developer to resort to other solutions for the architecture and the standard for its resource.
There are other ways to promote reactivity in a property instead of the entire object, such as MobX's Observable and Flutter's ValueNotifier, and that gives us a lot of choices. However, we lose some important architecture limits, which can put in check the project maintenance in the future. Therefore, it needs a standard to force limits on the individual reactivity of each property and thereby improve the maintainability of the components responsible for managing the states of the application.
Triple is a nickname to SSP (Segmented State Standard). Some packages were created to make it easier for developers to start using the standard. We'll call it an extension.
This project is distributed under the MIT License. See LICENSE.txt for more information.
✨ Usage
The SSP segments the state into 3 reactive parts, the state value (state), the error object (error), and the state loading action (loading).
These segments are observed in a listener or separate listeners. They can also be combined to obtain a new segment, always starting from the 3 main segments.
Installation
Dependencies
add the following dependencies to your pubspec.yaml file:
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the appropriate tag.
Don't forget to give the project a star! Thanks again!
Fork the Project
Create your Feature Branch (git checkout -b feature/AmazingFeature)
Commit your Changes (git commit -m 'Add some AmazingFeature')
Push to the Branch (git push origin feature/AmazingFeature)