State Management
State Management
Mendel Rosenblum
CS142 Lecture Notes - StateManagement
Our small, read-only photo app is deceptively simple
¡ñ
Model, View, Controller - All setup on startup and static
¡ð
¡ð
¡ñ
Add in Session State and object creation and updating
¡ð
¡ñ
Can have a nice modular design of view components.
Each MVC unit independently fetches their model data.
¡ö Some duplicate model data fetches (e.g. UserDetail & UserList)
Things get more complex for our single page app
Examples:
¡ð
¡ð
User add new comments or photos - model data of one view changed by another view
Users logs out and logins into the app with a different login name - big change in model data
CS142 Lecture Notes - StateManagement
Session state shared between frontend and backend
¡ñ
Must be kept in sync between the browser app and the server
¡ð
¡ñ
Server will need to reject any requests from users not logged in
¡ð
¡ñ
Who, if anyone, is logged in?
Model fetching done only at view/controller startup might not work
Consider transitions of your photo app
¡ð
¡ð
Login - Not logged in to logged in
¡ö At app startup most models are not available (e.g. sidenav user list) but become
available after login is completed.
Logout - Logged in to not logged in
¡ö Requests to web server that worked before will now fail
CS142 Lecture Notes - StateManagement
Models updates
¡ñ
Consider what happens when new objects like users, photos, or comments
are added.
¡ð
Models change
¡ñ
Controller fetching model only at startup might not work
¡ñ
Consider photo app adding a photo or comment
¡ð
Model refresh needed
CS142 Lecture Notes - StateManagement
Components are interested in outside events
¡ñ
How to keep a modular design but allow controllers to be notified of things
happening outside of it?
¡ð
¡ñ
One option: Explicit communication interfaces in components
¡ð
¡ñ
Example: a view component and an add component
ReactJS: Pass callback functions around to components
¡ö
Better option: Listener/emitter pattern
¡ð
Components registers interest (listen) and component detecting change signals (emit)
CS142 Lecture Notes - StateManagement
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- state of nevada cosmetology state board
- state by state teaching requirements
- state by state education statistics
- washington state treasury management s
- state of ohio hiring management system
- financial management and management accounting
- state government contract management software
- learning management state of michigan
- disability management state of michigan
- state of michigan learning management system
- state department records management policy
- washington state property management license