-
-
Notifications
You must be signed in to change notification settings - Fork 78
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
Get state from view #12
Comments
Hi, thanks! First of all Monkberry is not framework, it's library. So you can you is in any framework you want, or build your own. If you need to update state from server you can do something like this: fetch('https://...')
.then(response => response.json())
.then(state => view.update(state)); |
I'm going to write a bunch of articles about integrating Monkberry with frameworks like redux and other. |
sorry for the mistake :) That's not what I wanted to ask. What i wanted was something like this: var view = Monkberry.render(Template, document.body);
view.update({name: 'World'});
var data = view.getState();
$.post('url',data);``` |
No, this is not possible. This is main feature of Monkberry — it does not contains state, it's like pure function But get track of state it's pretty easily by your self: function update(state) {
Object.assign(currentState, state);
view.update(currenctState);
}
update({name: 'World'});
$.post('url', currenctState); |
Thanks 👍 But it would be great if the API had this type of helpers instead of doing some custom extra work. |
I think a dedicated |
Hi @Elfet , I've been trying this framework and it seems great, and with it's small size and benchmarks it's sounds like the "next JQuery must use in any site" framework.
But a was trying to make an ajax request and get to state (just like when update the view we just call view.update(someObject) it seams that (for now) it's doesn't has a way to get that state, for enable me, for instance make a request to the server.
I was expecting something like knockout observables, when you update something the render engine does it magic but at anytime I can get that model (in this case a view) and work with is data the generated the current view/html/template.
Am I missing something? Is this feature present or do you plan do give support? Or can you give some hint of how can I do this with this framework?
The text was updated successfully, but these errors were encountered: