dependabot[bot] on npm_and_yarn
Bump svelte from 3.0.0-beta.20 … (compare)
dependabot[bot] on npm_and_yarn
Bump svelte from 1.64.1 to 3.49… (compare)
dependabot[bot] on npm_and_yarn
dependabot[bot] on npm_and_yarn
Bump moment from 2.24.0 to 2.29… (compare)
dependabot[bot] on npm_and_yarn
dependabot[bot] on npm_and_yarn
Bump moment in /angular4-Bootst… (compare)
So I would not be concerned by that, in practice I have not seen it happening:
This could result in a long chain of actions that need to occur before the view is updated again
@arcfide
in the example wiring, the persistence will only ever happen after rendering,
I agree, I am not disputing that, what's important to note is that the pattern first appeared in 2016 and since then lots of discussions have happened and I have produced a lot of materials that may sometimes conflict with the current view of the pattern. It was shaped with discussions such as this one by the community, not just by me.
persisting the model should be considered a separate Action that is triggered automatically from the NAP due to changes in the model state
That would be my view, though, as I mentioned you have to distinguish between persisting the entire application state (model.persist()) and side effects of the current actions (persisting the data from a form, after proposal and application state mutation).
I'm thinking here of a waiting/loading bar or spinner
Yes, that's the tough case :-), last time I checked, even Redux was spinning it before entering Redux and the rendering of the application state would them stop it. What's original about SAM is the positioning of API calls with respect to the pattern (queries in actions and synchronous updates in the model).
The View can't update itself with a submitting icon, only the State() function changing the View can do that.
Yes, and again, if HTML was designed properly we would not have these questions, it mixes paradigms and therefore your implementation has to deal with that. You can't use a state representation, aka V = f(M), with a non declarative behavior.
submitting
order because it depends on how you implement it. Perhaps that blog sample (with updates on the backend) would help visualize how it could be done: https://github.com/jdubray/sam-samples/blob/master/crud-blog/blog.js
So, if I had a query, say, to filter the data with some search term, I was expecting that the model would be responsible for accepting a state update request to the data_view based on a set of filters (say, {search_terms: 'abc 123'}), so an acceptor might update the search query property, and then a reactor would apply a query function over the data property to produce the data_view property
The way I would implement that specific scenario is actually doing the query in the action and proposing the search results to the model to update the application state. That's kind of the beauty of SAM (as I see it) you can position queries and mutations very precisely, in relation to both the persisted state and the overall application state. Based on user preferences (application state) you could even sort/filter the search results in the model as you update the application state with the search results. That way neither the API nor the action (search) need to know anything about the application state. That is in sharp contrast with the event-handler pattern which need to know everything. I consider today the event-handler pattern an anti-pattern. Works in small scale (in scope) but as your application becomes more complex, its complexities grow exponentially. In other words, SAM suggests using an encapsulated global application state and I feel today that's a much better approach.
computation that is done over the model (that is, with the model as input) are not done with Actions, because Actions should not be aware of the model
Exactly, that's the essence of SAM, there is all that business logic that ends up in reducers in Redux or in event-handlers and SAM says, wait a second, they are different and you are better off decoupling them from each other, it's much easier to test and maintain.
1) We could submit the filtering action and then the model could update itself with the new filters, but not the resulting filtered data. Then the State function would take that data, see a new filter, and send a state update to the View that it has begun filtering, thus triggering the spinner.
That's one way to do it, but again I would not running any query from the model, only mutations.
2) We could enqueue two different actions, the first being a spinner activation action and then a filtering action which runs the filtering computation in the State function. This would mean that the State function isn't sending two state representations one after the other, but it increases complexity on the front of enqueuing two different actions, while also incurring the obligation to ensure that the two actions arrive and are handled by the model in the correct order.
Like with any pattern, there are trade-offs and contexts where SAM is easier to use. I want to emphasize that if HTML was 100% declarative that would make SAM the best choice for managing the application state. That being said, it's easy enough to deal with these corner cases programmatically. As an extreme, I created this 19 LOC library to look like react and of course you can implement a SAM structure/wiring below. I want to emphasize that SAM does not require any library, I created one because it helps visualize the pattern and its qualities, but once you understand the role and responsibilities of the pattern, everything should be easy to code. (https://medium.com/@metapgmr/hex-a-no-framework-approach-to-building-modern-web-apps-e43f74190b9c)