Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/midux.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import {
*/
let m = null;

/**
* This is function for unsabscribe redraw components
* @type {Function}
*/
let unsubscribeRedraw = null;

/**
* Initialize the library to utilize the exact reference to mithril as the base application
* @param {Function} mithrilModule reference to the application's mithril instance
Expand Down Expand Up @@ -92,6 +98,16 @@ export const connect = (
this.unsubscribe = this.store.subscribe(
this.handleUpdate.bind(this, vnode)
);

if (typeof unsubscribeRedraw === "function") {
unsubscribeRedraw();
unsubscribeRedraw = null;
}

unsubscribeRedraw = this.store.subscribe(
this.handleRedraw.bind(this)
);

this.handleUpdate(vnode);
}
};
Expand All @@ -109,7 +125,9 @@ export const connect = (
const storeState = mapStateToProps(this.store.getState(), ownProps);

this.componentState(storeState);

};

this.handleRedraw = () => {
setTimeout(m.redraw);
};

Expand Down