Skip to content

Commit

Permalink
Merge pull request #297 from rafaqz/body
Browse files Browse the repository at this point in the history
add `body` keyword to `Window`
  • Loading branch information
pfitzseb authored Jan 3, 2023
2 parents 6e1e0df + 4627d2b commit 5055484
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/AtomShell/window.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,16 @@ const window_defaults = Dict(

raw_window(a::Electron, opts) = @js a createWindow($(merge(window_defaults, opts)))

function Window(a::Shell, opts::AbstractDict = Dict(); async=false)
function Window(a::Shell, opts::AbstractDict = Dict(); async=false, body=nothing)
# TODO: Custom urls don't support async b/c don't load Blink.js. (Same as https://github.com/JunoLab/Blink.jl/issues/150)
return haskey(opts, :url) ?
window = haskey(opts, :url) ?
Window(raw_window(a, opts), a, nothing, nothing) :
Window(a, Page(), opts, async=async)
Window(a, Page(), opts; async=async)
isnothing(body) || body!(window, body)
return window
end

function Window(a::Shell, content::Page, opts::AbstractDict = Dict(); async=false)
function Window(a::Shell, content::Page, opts::AbstractDict = Dict(); async=false, body=nothing)
id, callback_cond = Blink.callback!()
url = Blink.localurl(content) * "?callback=$id"

Expand All @@ -74,6 +76,8 @@ function Window(a::Shell, content::Page, opts::AbstractDict = Dict(); async=fals
wait(w)
end

isnothing(body) || body!(w, body)

return w
end

Expand Down
3 changes: 1 addition & 2 deletions test/webio.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ end
end

@testset "button click" begin
w = Window(Dict(:show => false))
scope = Scope()
obs = Observable(scope, "obs", false)
obschannel = Channel(1)
Expand All @@ -47,7 +46,7 @@ end
end
)
))
body!(w, scope)
w = Window(Dict(:show => false); body=scope)

# Sleep to allow WebIO scope to mount in Electron
sleep(0.25)
Expand Down

2 comments on commit 5055484

@pfitzseb
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/74985

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.6 -m "<description of version>" 5055484c0402ddf9764a10de93c9135a30987cf2
git push origin v0.12.6

Please sign in to comment.