Named exports from ol/Observable

This commit is contained in:
Frederic Junod
2018-02-21 09:01:08 +01:00
parent e2854b3176
commit 2fd75566fb
6 changed files with 12 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
import Feature from '../src/ol/Feature.js'; import Feature from '../src/ol/Feature.js';
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import Observable from '../src/ol/Observable.js'; import {unByKey} from '../src/ol/Observable.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import {defaults as defaultControls} from '../src/ol/control.js'; import {defaults as defaultControls} from '../src/ol/control.js';
import {easeOut} from '../src/ol/easing.js'; import {easeOut} from '../src/ol/easing.js';
@@ -80,7 +80,7 @@ function flash(feature) {
vectorContext.setStyle(style); vectorContext.setStyle(style);
vectorContext.drawGeometry(flashGeom); vectorContext.drawGeometry(flashGeom);
if (elapsed > duration) { if (elapsed > duration) {
Observable.unByKey(listenerKey); unByKey(listenerKey);
return; return;
} }
// tell OpenLayers to continue postcompose animation // tell OpenLayers to continue postcompose animation

View File

@@ -1,5 +1,5 @@
import Map from '../src/ol/Map.js'; import Map from '../src/ol/Map.js';
import Observable from '../src/ol/Observable.js'; import {unByKey} from '../src/ol/Observable.js';
import Overlay from '../src/ol/Overlay.js'; import Overlay from '../src/ol/Overlay.js';
import {getArea, getLength} from '../src/ol/sphere.js'; import {getArea, getLength} from '../src/ol/sphere.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
@@ -238,7 +238,7 @@ function addInteraction() {
// unset tooltip so that a new one can be created // unset tooltip so that a new one can be created
measureTooltipElement = null; measureTooltipElement = null;
createMeasureTooltip(); createMeasureTooltip();
Observable.unByKey(listener); unByKey(listener);
}, this); }, this);
} }

View File

@@ -41,7 +41,7 @@ inherits(Observable, EventTarget);
* or `once()` (or an array of keys). * or `once()` (or an array of keys).
* @api * @api
*/ */
Observable.unByKey = function(key) { export function unByKey(key) {
if (Array.isArray(key)) { if (Array.isArray(key)) {
for (let i = 0, ii = key.length; i < ii; ++i) { for (let i = 0, ii = key.length; i < ii; ++i) {
unlistenByKey(key[i]); unlistenByKey(key[i]);
@@ -49,7 +49,7 @@ Observable.unByKey = function(key) {
} else { } else {
unlistenByKey(/** @type {ol.EventsKey} */ (key)); unlistenByKey(/** @type {ol.EventsKey} */ (key));
} }
}; }
/** /**

View File

@@ -1,5 +1,5 @@
import EventTarget from '../../../src/ol/events/EventTarget.js'; import EventTarget from '../../../src/ol/events/EventTarget.js';
import Observable from '../../../src/ol/Observable.js'; import Observable, {unByKey} from '../../../src/ol/Observable.js';
describe('ol.Observable', function() { describe('ol.Observable', function() {
@@ -138,7 +138,7 @@ describe('ol.Observable', function() {
observable.dispatchEvent('foo'); observable.dispatchEvent('foo');
expect(listener.calledOnce).to.be(true); expect(listener.calledOnce).to.be(true);
Observable.unByKey(key); unByKey(key);
observable.dispatchEvent('foo'); observable.dispatchEvent('foo');
expect(listener.callCount).to.be(1); expect(listener.callCount).to.be(1);
}); });

View File

@@ -1,6 +1,6 @@
import BingMaps from '../../../../src/ol/source/BingMaps.js'; import BingMaps from '../../../../src/ol/source/BingMaps.js';
import {quadKey} from '../../../../src/ol/tilecoord.js'; import {quadKey} from '../../../../src/ol/tilecoord.js';
import Observable from '../../../../src/ol/Observable.js'; import {unByKey} from '../../../../src/ol/Observable.js';
describe('ol.source.BingMaps', function() { describe('ol.source.BingMaps', function() {
@@ -24,7 +24,7 @@ describe('ol.source.BingMaps', function() {
const key = source.on('change', function() { const key = source.on('change', function() {
if (source.getState() === 'ready') { if (source.getState() === 'ready') {
Observable.unByKey(key); unByKey(key);
tileGrid = source.getTileGrid(); tileGrid = source.getTileGrid();
done(); done();
} }

View File

@@ -1,6 +1,6 @@
import Source from '../../../../src/ol/source/Source.js'; import Source from '../../../../src/ol/source/Source.js';
import TileJSON from '../../../../src/ol/source/TileJSON.js'; import TileJSON from '../../../../src/ol/source/TileJSON.js';
import Observable from '../../../../src/ol/Observable.js'; import {unByKey} from '../../../../src/ol/Observable.js';
describe('ol.source.TileJSON', function() { describe('ol.source.TileJSON', function() {
@@ -115,7 +115,7 @@ describe('ol.source.TileJSON', function() {
}); });
const key = source.on('change', function() { const key = source.on('change', function() {
if (source.getState() === 'ready') { if (source.getState() === 'ready') {
Observable.unByKey(key); unByKey(key);
tileGrid = source.getTileGrid(); tileGrid = source.getTileGrid();
done(); done();
} }