Skip to content
This repository was archived by the owner on Sep 7, 2018. It is now read-only.
This repository was archived by the owner on Sep 7, 2018. It is now read-only.

getCurrentWindow inconsistent callback behavior #314

Description

@jleft

getCurrentWindow(callback, errorCallback) always returns a Window but it may not be ready to use until the callback has been called (observed in OpenFin implementation).

However, sometimes the callback is never called; as a consumer of the API, I don't know when I can safely use the Window object returned by this method.

Annotated code in the API with comments to highlight the issue:

static getCurrentWindow(callback?: (win: Window) => void, errorCallback?: (err?: any) => void) {
  if (currentWindow) {
    // In this branch, callback will never be called,
    // how do I know that currentWindow is ready to use?
    return currentWindow;
  }
  
  // In this branch, I have to wait until callback is called,
  // otherwise currentWindow may not be ready
  currentWindow = new Window(null, callback, errorCallback);
  return currentWindow;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions