workerize icon indicating copy to clipboard operation
workerize copied to clipboard

Consider removing expose(), call() and kill() ?

Open ribizli opened this issue 7 years ago • 4 comments

	worker.expose = methodName => {
		worker[i] = function() {
			return worker.call(methodName, [].slice.call(arguments));
		};
	};

Instead methodName parameter should be used:

	worker.expose = methodName => {
		worker[methodName] = function() {
			return worker.call(methodName, [].slice.call(arguments));
		};
	};

Beside that I don't see why the call and expose methods are accessible from outside. (Don't assign to worker at all) The purpose of the kill method is also not clear for me.

ribizli avatar Mar 20 '18 08:03 ribizli

heh - i was a mistake, but it still worked for automatic methods because it was using i from the outer scope.

call and expose are both exposed because sometimes autogeneration could fail. It might be worth looking into the byte cost for this, though - I'm not sure they are widely used. Kill is just a way to shut down the worker before terminating it, and probably worth applying the same scrutiny as the other two.

developit avatar Apr 05 '18 18:04 developit

Is it possible to terminate a worker from the main app and if so how? Calling terminate() or kill() doesn't work. Thanks.

vano21 avatar Apr 14 '18 09:04 vano21

terminate() should work.

developit avatar May 11 '18 06:05 developit

A fix for terminate() not working - https://github.com/developit/workerize/pull/28

boblauer avatar May 11 '18 19:05 boblauer