view src/djol/listen.js @ 33:8af8e840dd49

added return fn
author nickolay
date Wed, 05 Jun 2019 17:44:17 +0300
parents f0035923ff3e
children
line wrap: on
line source

define(["ol"], function(ol) {

    var listen = function(target, event, callback) {
        var key = target.on(event, callback);
        return {
            remove : function() {
                ol.Observable.unByKey(key);
            }
        };
    };

    listen.once =  function(target, event, callback) {
        var key = target.once(event, callback);
        return {
            remove : function() {
                ol.Observable.unByKey(key);
            }
        };
    };

    return listen;
});