on master help sign in
Allow disposing the current Elm module from outside.
521f94bLaszlo Pandy
runtime/Init.js+11−1
@@ -93,6 +93,11 @@ function init(display, container, module, moduleToReplace) {
93 return newElm;
93 return newElm;
94 }
94 }
95
95
96+ function dispose() {
97+ removeListeners(listeners);
98+ inputs = [];
99+ }
100+
96 var Module = {};
101 var Module = {};
97 var reportAnyErrors = function() {};
102 var reportAnyErrors = function() {};
98 try {
103 try {
@@ -117,7 +122,12 @@ function init(display, container, module, moduleToReplace) {
117 }
122 }
118
123
119 reportAnyErrors();
124 reportAnyErrors();
125+ return {
120− return { send:send, recv:recv, swap:swap };
126+ send:send,
127+ recv:recv,
128+ swap:swap,
129+ dispose:dispose
130+ };
121};
131};
122
132
123function filterListeners(inputs, listeners) {
133function filterListeners(inputs, listeners) {