New to Mithril but really want to like it. I coded demo app a few weeks ago using React and Redux for state management. I also used a library to connect the two, but it all works and can be seen at http://curiousercreative.com/demos/bankDemo/. After reading up on Mithril and liking a lot of what I read, I decided to translate the same demo app into Mithril + Redux, but I can't seem to get my Mithril mounted components to update/redraw and so updates to my Redux store (state) aren't ever reflected in the UI. From my app's js/app.js lines ~144-162, I have my Redux callback and my two top level Mithril components being mounted and passed our state.
// redraws Mithril whenever an action is dispatched
store.subscribe(function () {
console.log('happening');
m.redraw.strategy('all');
m.redraw(true);
});
// Render Mithril
// content
m.mount(
document.getElementById('content'),
m.component(App, store.getState())
);
// nav
m.mount(
document.getElementById('navContainer'),
m.component(Nav, store.getState())
);
If you open a console at http://curiousercreative.com/demos/bankDemo-mithril/, you'll notice a log entry every time you click on a new link (which changes the hash which updates the Redux state store). You'll also notice in the code above that every time that log occurs, a forced redraw of Mithril is supposed to occur, but of course the UI doesn't change. Compare it's behavior to the React demo app further above. In the app's js/components.js file, our two top level components take this state object as an argument and pass it down to their child components.
var App = {
controller: function (args) {
this.activePageId = args.activePageId;
this.accounts = args.accounts;
...
var Nav = {
controller: function (args) {
this.activePageId = args.activePageId;
this.accounts = args.accounts;
...
Why isn't Mithril redrawing?