-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the right way to call something after an action call? #728
Comments
Hello @dmitrykurmanov, Updating the DOM will be the last thing that will be perfomed when actions are called. If you want to trigger another action only after the DOM is updated, you whould take a look at the But you will not have an easy way to know which actions were called before. What are you trying to perform ? Why do you need to call the action after the DOM update ? |
@Swizz thank you for the answer. I am trying to find a way to create a third party widget (component) based on hyperapp. It is just investigation. User of that widget may want to add action listeners (before - it is easy and after). So the after listener should be call after action completely done the job. I thought about
I could create repo with an example of widget if it will help. PS I think about cross-frameworks web components based on hyperapp because of its size. |
Oh I've missed hyperapp v2 branch, I will take a look! I think we can close the issue. I will create an example and return back later :) |
SummaryState updates are immediate, but it's impossible to retroactively change the You can find out the new state inside the action like this. export const bazBam = state => ({ value: !state.value })
export const fooBar = (state, actions) => {
console.log(state) //=> {value:true}
const newState = actions.bazBam()
console.log(state) //=> {value:true}
console.log(newState) //=> {value:false}
} import { app } from "hyperapp"
import * as actions from "./actions"
const state = { value: true }
app(state, actions, view, container) Difference with V2You call actions inside other actions to update different state slices or create side effects, however:
|
Hello!
I've found two ways to do it:
but in fact when console.log run DOM not updated yet.
It does what I need, but I think it is bad practice (may be not)
Could anyone please help me with it. Thanks.
The text was updated successfully, but these errors were encountered: