Comments (5)
I think it's the expected behavior, since you're bypassing Mithril's controller
handling when creating the Test
objects yourself and assigning them in a normal Haxe class. If you use routes, you may get a different result since all controllers are called again when the route changes.
The more I use mithril-hx, the less I'm relying on the controller
method, since it works as a constructor in Mithril, which we already have with Haxe's classes.
from mithril-hx.
Using the router works as expected, but in this case it's not a good fit. I'm using it for developing a cordova app, where I have no use for routing really. I mainly use the controller method in cases where I need some stuff done when the components mounts/unmounts (for example adding/removing an event listener to the window object). The combination of controller/unonload is really useful for that. I could replace it by using config on the root element of the view (with ctx.onunload), but that means I'm relying on the component to be rendered first. So I'm unsure what the right way to do this would be.
from mithril-hx.
Ok, I see! Looking at https://lhorie.github.io/mithril/mithril.component.html#unloading-components it seems that you have to call mount
again to make your case work, instead of using redraw
(which is only view-related). Does it work to replace the M.redraw
calls in your example with the same M.mount
call?
from mithril-hx.
Thanks, I see. I've misinterpreted the use of the controller method. I've solved this for my case by calling a mount/unmount method on the components since they all pass through the same method. Something like this:
public function setView(view) {
if (component != null) component.unmount();
component = view;
component.mount();
}
Thanks for the help and your work on the externs!
from mithril-hx.
Glad to help. :)
from mithril-hx.
Related Issues (20)
- Problems with @prop HOT 2
- Multiple properties in sugaertags HOT 2
- replacing prop by custom getter, setter HOT 4
- Changing/adding elements to HEAD HOT 1
- How to handle sub-components HOT 1
- Putting together a table from functions or components HOT 1
- @prop not working with haxe dev version (3.3.0) HOT 4
- Mithril __init__ code, causes problems if included twice HOT 1
- Unknown identifier : M HOT 3
- Error when using mithril 0.27.0 HOT 5
- mitrhil-hx not working properly with mithril > 0.2.0 HOT 2
- CS Serverrendering: namespace error (T4, T3) HOT 5
- component args not passed to view nor controller HOT 1
- Wiki bug - MVC HOT 1
- Does / will this work with mithril@rewrite (1.0)? HOT 2
- When running under the latest node, `GLOBAL` is deprecated in favour of `global` HOT 1
- Works with Mithril 2? HOT 3
- Vnode state is no longer typed? HOT 6
- Broken in Haxe 4.2? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mithril-hx.