From c7fb2ba646fcfad94fc9102955caa7218d6b82db Mon Sep 17 00:00:00 2001 From: Marius Petcu Date: Wed, 20 May 2020 15:58:04 +0300 Subject: [PATCH] Add sequential loading flag (#62) --- README.md | 1 + monarch/monarch.lua | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e8943c..411dd78 100644 --- a/README.md +++ b/README.md @@ -318,6 +318,7 @@ The options table can contain the following fields: * ```clear``` (boolean) - If the `clear` flag is set Monarch will search the stack for the screen that is to be shown. If the screen already exists in the stack and the clear flag is set Monarch will remove all screens between the current top and the screen in question. * ```reload``` (boolean) - If the `reload` flag is set Monarch will reload the collection proxy if it's already loaded (this can happen if the previous screen was a popup). * ```no_stack``` (boolean) - If the `no_stack` flag is set Monarch will load the screen without adding it to the screen stack. +* ```sequential``` (boolean) - If the `sequential` flag is set Monarch will start loading the screen only after the previous screen finished transitioning out. ### monarch.hide(screen_id, [callback]) diff --git a/monarch/monarch.lua b/monarch/monarch.lua index d04c2ef..3012a7d 100644 --- a/monarch/monarch.lua +++ b/monarch/monarch.lua @@ -647,6 +647,8 @@ end -- * clear - Set to true if the stack should be cleared down to an existing instance of the screen -- * reload - Set to true if screen should be reloaded if it already exists in the stack and is loaded. -- This would be the case if doing a show() from a popup on the screen just below the popup. +-- * sequential - Set to true to wait for the previous screen to show itself out before starting the +-- show in transition even when transitioning to a different scene ID. -- @param data (*) - Optional data to set on the screen. Can be retrieved by the data() function -- @param cb (function) - Optional callback to invoke when screen is shown function M.show(id, options, data, cb) @@ -692,7 +694,7 @@ function M.show(id, options, data, cb) -- wait until we are done if showing the same screen as is already visible local same_screen = top and top.id == screen.id show_out(top, screen, callbacks.track()) - if same_screen then + if same_screen or (options and options.sequential) then callbacks.yield_until_done() end end