Clean up internal dependencies
This commit is contained in:
Родитель
3240c36f7b
Коммит
924bcc7bd2
|
@ -5,8 +5,6 @@
|
|||
"main": "dist/index",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@bingads-webui-universal/observer-pattern": "*",
|
||||
"@bingads-webui-universal/primitive-utilities": "^1.4.5",
|
||||
"bluebird": "3.5.0",
|
||||
"json-stable-stringify": "*",
|
||||
"prop-types": ">=15.6.0",
|
||||
|
@ -17,12 +15,6 @@
|
|||
"uuid": "^3.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@bingads-webui/mca-odata-schemas": ">=1.0.0-alpha.2019091919",
|
||||
"@bingads-webui/edm-core": ">=1.0.0",
|
||||
"@bingads-webui/edm-odata": "^1.1.6",
|
||||
"@bingads-webui/edm-resource-identifiers": ">=1.0.0",
|
||||
"@bingads-webui/http-util": "^1.0.0",
|
||||
"@bingads-webui/reflection": ">=1.0.0",
|
||||
"fetch-mock": "^9.10.1",
|
||||
"jquery": "2.2.4",
|
||||
"json-stable-stringify": "*",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable no-param-reassign */
|
||||
import _ from 'underscore';
|
||||
|
||||
import { getTimestamp } from '@bingads-webui-universal/primitive-utilities';
|
||||
import { getTimestamp } from '../../utils/primitive-utilities';
|
||||
|
||||
export const defaultStubOptions = {
|
||||
serverErrorCodes: [-1],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Subject } from '@bingads-webui-universal/observer-pattern';
|
||||
import _ from 'underscore';
|
||||
import { Record } from './record';
|
||||
import { OVERREACT_ID_FIELD_NAME } from './consts';
|
||||
import { Subject } from '../utils/observer-pattern'
|
||||
|
||||
export class RecordGroup extends Subject {
|
||||
constructor(schemaType) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Subject } from '@bingads-webui-universal/observer-pattern';
|
||||
import _ from 'underscore';
|
||||
import { Subject } from '../../utils/observer-pattern';
|
||||
|
||||
export class DataRef extends Subject {
|
||||
constructor(key) {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export { Subject } from './subject';
|
|
@ -0,0 +1,48 @@
|
|||
/* global Set */
|
||||
// Use the basic APIs of ES6 Set. If your site supports browsers not
|
||||
// having Set natively, you should use a polyfill
|
||||
|
||||
/* Subject to observe */
|
||||
export class Subject {
|
||||
constructor() {
|
||||
this.observers = new Set();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribe an observer to the subject
|
||||
* @param {Object} observer - The observer subscribing to the subject
|
||||
* @returns {void}
|
||||
*/
|
||||
subscribe(observer) {
|
||||
if (!(observer instanceof Object)) {
|
||||
throw new Error('Invalid observer');
|
||||
}
|
||||
this.observers.add(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe an observer from the subject
|
||||
* @param {Object} observer - The observer to unsubscribe
|
||||
* @returns {void}
|
||||
*/
|
||||
unsubscribe(observer) {
|
||||
this.observers.delete(observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the observers for a certain action
|
||||
* @param {string} action -
|
||||
* Name of the action, it will map to the handler method name on the observer
|
||||
* @param {...*} args - Additional arguments
|
||||
* @returns {void}
|
||||
*/
|
||||
notify(action, ...args) {
|
||||
this.observers.forEach((observer) => {
|
||||
if (typeof observer[action] === 'function') {
|
||||
observer[action](this, ...args);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
|
||||
/**
|
||||
* Get the current timestamp
|
||||
* @returns {number} - the timestamp since epoch in milliseconds
|
||||
*/
|
||||
export function getTimestamp() {
|
||||
// TODO: this method should not be here, as it depends on Web API performance
|
||||
if (window.performance && window.performance.now && window.performance.timing) {
|
||||
return window.performance.timing.navigationStart + window.performance.now();
|
||||
}
|
||||
|
||||
return Date.now();
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from './date';
|
Загрузка…
Ссылка в новой задаче