Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(context: DocumentRegistry.Context, rendermime: RenderMime) {
super();
this.addClass(GEOJSON_CLASS);
this.layout = new PanelLayout();
this.title.label = context.path.split('/').pop();
this._rendermime = rendermime;
rendermime.resolver = context;
this._context = context;
context.pathChanged.connect(this._onPathChanged, this);
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: context.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(this.update, this);
}
constructor(context: DocumentRegistry.Context, rendermime: RenderMime) {
super();
this.addClass(JSON_CLASS);
this.layout = new PanelLayout();
this.title.label = context.path.split('/').pop();
this._rendermime = rendermime;
rendermime.resolver = context;
this._context = context;
context.pathChanged.connect(this._onPathChanged, this);
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: context.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(this.update, this);
}
constructor(context) {
super();
this._context = context;
this._onPathChanged();
this.addClass(CLASS_NAME);
context.ready.then(() => {
this.update();
/* Re-render when the document content changes */
context.model.contentChanged.connect(this.update, this);
/* Re-render when the document path changes */
context.fileChanged.connect(this.update, this);
});
/* Update title when path changes */
context.pathChanged.connect(this._onPathChanged, this);
/* Throttle re-renders until changes have stopped */
this._monitor = new ActivityMonitor({
signal: context.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(this.update, this);
}
.then(() => {
// After rendering for the first time, send an activation request if we
// are currently focused.
if (this.node === document.activeElement) {
// We want to synchronously send (not post) the activate message, while
// we know this node still has focus.
MessageLoop.sendMessage(this.renderer, Widget.Msg.ActivateRequest);
}
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: this._context.model.contentChanged,
timeout: options.renderTimeout
});
this._monitor.activityStopped.connect(this.update, this);
this._ready.resolve(undefined);
})
.catch(reason => {
constructor(options: MarkdownCell.IOptions) {
super(options);
this.addClass(MARKDOWN_CELL_CLASS);
// Ensure we can resolve attachments:
this._rendermime = options.rendermime.clone({
resolver: new AttachmentsResolver({
parent: options.rendermime.resolver,
model: this.model.attachments
})
});
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: this.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(() => {
if (this._rendered) {
this.update();
}
}, this);
void this._updateRenderedInput().then(() => {
this._ready.resolve(void 0);
});
this.renderInput(this._renderer);
}
constructor(options: MarkdownCell.IOptions) {
super(options);
this.addClass(MARKDOWN_CELL_CLASS);
// Ensure we can resolve attachments:
this._rendermime = options.rendermime.clone({
resolver: new AttachmentsResolver({
parent: options.rendermime.resolver,
model: this.model.attachments
})
});
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: this.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(() => {
if (this._rendered) {
this.update();
}
}, this);
void this._updateRenderedInput().then(() => {
this._ready.resolve(void 0);
});
this.renderInput(this._renderer);
}
void this.context.ready.then(async () => {
await this._render();
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: this.context.model.contentChanged,
timeout: this._config.renderTimeout
});
this._monitor.activityStopped.connect(
this.update,
this
);
this._ready.resolve(undefined);
});
}
void this._context.ready.then(() => {
this._updateGrid();
this._revealed.resolve(undefined);
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: context.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(this._updateGrid, this);
});
}
void this.context.ready.then(() => {
this.update();
// Throttle the rendering rate of the widget.
this._monitor = new ActivityMonitor({
signal: this.context.model.contentChanged,
timeout: RENDER_TIMEOUT
});
this._monitor.activityStopped.connect(this.update, this);
});
it('should be emitted after the signal has fired and a timeout', async () => {
let called = false;
const monitor = new ActivityMonitor({ signal, timeout: 100 });
monitor.activityStopped.connect((sender, args) => {
expect(sender).to.equal(monitor);
expect(args.sender).to.equal(testObj);
expect(args.args).to.equal(10);
called = true;
});
signal.emit(10);
expect(called).to.equal(false);
await sleep(100);
expect(called).to.equal(true);
});
});