autoscale: true
The Concept of Almin

Almin is a State management library for JavaScript

Almin features
- Scalable
- Medium-small(1,000LOC) – Large(100,000LOC)
- Testable
- Implement UseCase/Store/Domain as component
- Debuggable
- Logger/DevTools/Performance monitoring
- Layered Architecture
Different team structures imply different architectural decisions.-- Clean Architecture Robert C. Martin
The Concept of Almin
- WriteYour domain inYour code
- Split upRead stack andWrite stack
- Unidirectional data flow
- PreferReadable code toWritable code
- Monitor everything
WriteYour domain inYour code
- You can control domain layer
- You can writeyour domain withPure JavaScript
- Your domain isnot need to subclass of Almin things
- Almin support application layer
- Application layer use your domain model
- If you stop to use almin, youdon't need to rewrite your domain
Example: UseCase
Almin proviceUseCase
class that is a part of application layer
import { UseCase } from "almin";import yourDomain from "./your-domain";export ApplicationUseCase extends UseCase { execute(){ // Application Layer use your domain yourDomain.doSomething(); }}
Split upRead stack andWrite stack
- In Flux/Redux
- Store hasApplication logic/state(M) andView state(N)
- The Complexity:N × M (multiplication)
- In Almin
- Domain hasApplication logic/state(M) – Write state
- Store hasView state(N) - Read state
- The Complexity:N + M (addition)
Related topic: Command Query Responsibility Segregation(CQRS)
Example: Repository
- Almin help to supportRepository pattern
- You can save your domain(application state) into the repository
- Store readapplication state from therepository
- Store convert theapplication state toview state
Realted topic: Model View ViewModel(MVVM), ViewModel
Unidirectional data flow
View -> UseCase -> Store ... -> View -> UseCase -> Store
- UseCase only reportsuccess or failure that isPromise
- UseCase can write toStore, But can not read from Store
- Store does't know anyUseCase
- View can not write state toStore directly
- View can execute anyUseCase
- View can observe the change ofStore
Related topic: Flux

PreferReadable code toWritable code
- Almin preferExplicit/Readable code toImplicit/Writable code
- Almin supportTypeScript language and Almin istype-safe
- Pros
- No magic code
- Just write and Just work
- Cons
Monitor everything


Conclusion

[fit]Almin is for thinking code
[8]