this is a thinking out loud to myself.
how to prepare a SPA in different frameworks/libraries but also in angular
-
ng new
create-react-app
vue cli
- enable router
- enable i18n strategy
- enable store / reduxy stuff
- bind router into store
- ensure your API with smthng like or
curls
/ postmany stugff
- test GET / POST/ UPDATE
- brief moment of think: do we need to auth? if so handle auth token with like setLocalStorage
- create an entityfolder for selected endpoint, (if angular, also create a module here!!)
- create model/type declartion (only if typescript, which we prefer) of entities
- create service to consume any http-client (eg axios) // consider auth process
- test GET / POST/ UPDATE
loadAll()
,oneOneById()
,postNew()
,update()
,delete()
for selected entity
- test servicemethods in bare minimum but routable component, most liekly in lifecycle method of given framework
- from now on we would need to distungiush from framework to framework/library which should be more articles,
in angular -which we atm work with- we go with:
- create routeresolvers
- prepare actions / reducer / selectors from ngrx, naivly bind http service into the loadaction (we like ngrx-entity here)
- access store in template and trigger action for udf to ensure actions work
- create effect for entity ->
loadAllEntity
-> http-service -> dispatchloadAllEntitySucess
, bind result into store - we forget about, register router, effect, store, store-router in module, considering it silently given from now on, knowing forRoot() and forFeature().
- remove 3 from template
- consume loadEntity from action in routeresolver -> which should also will trigger the effect -> which will trigger the http -> which will trigger store binding
- bind observable/subscriber to store in template list view
- prepare route for single entity
- access route, write resolver that gains single entity from store / write actions..... from here on
- rinse repaet
quod erat demonstrandum.
Top comments (0)