Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ref for active electron process, add some Base methods. #230

Merged
merged 3 commits into from
Jan 1, 2020

Conversation

twavv
Copy link
Member

@twavv twavv commented Dec 28, 2019

There are some parts of the Blink API that I'd like to change around a bit. I think there are parts that are "cludgy" and lead to some strange errors (à la #191).

If it's okay, I'd like to rework some parts of the API with the strategy of maintaining backward compatibility and with the end goal of possibly removing some of those deprecations and releasing a new major version.

This is related to the work I've been doing trying to whip WebIO into shape. The end goal is to make everything in the JuliaGizmos universe work together more seamlessly.

@twavv twavv requested review from rdeits and NHDaly December 28, 2019 21:39
@twavv
Copy link
Member Author

twavv commented Dec 28, 2019

Some things I'd like to change:

  • Fix whatever that bug was (I was able to track it down at one point but I've forgotten) by any means necessary
  • Add ! postfixes to all modifying methods (e.g. size should be size!)
  • Use methods on Base functions where appropriate instead of defining our own (e.g., Base.close(window) instead of Blink.AtomShell.quit(window))

global _shell
_shell ≠ nothing && active(_shell) && return _shell
_shell = init(debug = debug)
_active_electron_process = Ref{Union{Electron, Nothing}}(nothing)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be marked const for a significant performance improvement. I also personally prefer ALL_CAPS for global constants, but if you're happy with _leading_underscore notation that's fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, thanks.

I think I personally like the lowercase here because it's const but not immutable (though I think I've been inconsistent with that in other places).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Don't forget to make this const before merging

Suggested change
_active_electron_process = Ref{Union{Electron, Nothing}}(nothing)
const _active_electron_process = Ref{Union{Electron, Nothing}}(nothing)

Copy link
Collaborator

@NHDaly NHDaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

Comment on lines 138 to 139
`Electron` instance. If there *is* an active instance, this function returns
that instance without regards to whether or not the `debug` setting matches.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to be super thorough, we could check if the requested debug settings match the existing debug settings, and if not, print a warning or something?

global _shell
_shell ≠ nothing && active(_shell) && return _shell
_shell = init(debug = debug)
_active_electron_process = Ref{Union{Electron, Nothing}}(nothing)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) Don't forget to make this const before merging

Suggested change
_active_electron_process = Ref{Union{Electron, Nothing}}(nothing)
const _active_electron_process = Ref{Union{Electron, Nothing}}(nothing)

@twavv twavv merged commit be55f4e into JuliaGizmos:master Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants