function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
import useForceUpdate from './useForceUpdate';
import useStableMemo from './useStableMemo';
export var ObservableMap = /*#__PURE__*/function (_Map) {
_inheritsLoose(ObservableMap, _Map);
function ObservableMap(listener, init) {
var _this;
_this = _Map.call(this, init) || this;
_this.listener = listener;
return _this;
}
var _proto = ObservableMap.prototype;
_proto.set = function set(key, value) {
_Map.prototype.set.call(this, key, value); // When initializing the Map, the base Map calls this.set() before the
// listener is assigned so it will be undefined
if (this.listener) this.listener(this);
return this;
};
_proto.delete = function _delete(key) {
var result = _Map.prototype.delete.call(this, key);
this.listener(this);
return result;
};
_proto.clear = function clear() {
_Map.prototype.clear.call(this);
this.listener(this);
};
return ObservableMap;
}( /*#__PURE__*/_wrapNativeSuper(Map));
/**
* Create and return a [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) that triggers rerenders when it's updated.