mirror of
https://github.com/britzl/monarch.git
synced 2025-11-26 19:00:53 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ba3064749 | ||
|
|
b78b896ada | ||
|
|
679482f84d |
@@ -222,6 +222,13 @@ IMPORTANT! If you provide a function you must also make sure to call `monarch.on
|
|||||||
* `fn_or_url` (function) - The function to call or URL to send message to
|
* `fn_or_url` (function) - The function to call or URL to send message to
|
||||||
|
|
||||||
|
|
||||||
|
## monarch.has_missing_resources(screen_id)
|
||||||
|
Check if a screen has any missing resources. If the screen is loaded by a collection proxy with Load Dynamically this will use `collectionproxy.missing_resources()`. For other cases this function will always return false.
|
||||||
|
|
||||||
|
**RETURN**
|
||||||
|
* `result` (boolean) - true if the screen has missing resources
|
||||||
|
|
||||||
|
|
||||||
## monarch.debug()
|
## monarch.debug()
|
||||||
Enable verbose logging of the internals of Monarch.
|
Enable verbose logging of the internals of Monarch.
|
||||||
|
|
||||||
|
|||||||
@@ -430,7 +430,9 @@ local function unload(screen, force)
|
|||||||
elseif screen.factory then
|
elseif screen.factory then
|
||||||
log("unload() factory", screen.id)
|
log("unload() factory", screen.id)
|
||||||
for id, instance in pairs(screen.factory_ids) do
|
for id, instance in pairs(screen.factory_ids) do
|
||||||
go.delete(instance)
|
if go.exists(instance) then
|
||||||
|
go.delete(instance)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
screen.factory_ids = nil
|
screen.factory_ids = nil
|
||||||
if screen.auto_preload and not force then
|
if screen.auto_preload and not force then
|
||||||
@@ -462,8 +464,7 @@ local function preload(screen)
|
|||||||
screen.preloading = true
|
screen.preloading = true
|
||||||
if screen.proxy then
|
if screen.proxy then
|
||||||
log("preload() proxy")
|
log("preload() proxy")
|
||||||
local missing_resources = collectionproxy.missing_resources(screen.proxy)
|
if M.has_missing_resources(screen.id) then
|
||||||
if #missing_resources > 0 then
|
|
||||||
local error_message = ("preload() collection proxy %s is missing resources"):format(tostring(screen.id))
|
local error_message = ("preload() collection proxy %s is missing resources"):format(tostring(screen.id))
|
||||||
log(error_message)
|
log(error_message)
|
||||||
screen.preloading = false
|
screen.preloading = false
|
||||||
@@ -1131,6 +1132,20 @@ function M.preload(id, options, cb)
|
|||||||
return true -- return true for legacy reasons (before queue existed)
|
return true -- return true for legacy reasons (before queue existed)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Check if a screen has missing resources, always returns false for factory
|
||||||
|
-- @param id (string|hash) - Id of the screen to preload
|
||||||
|
function M.has_missing_resources(id)
|
||||||
|
assert(id, "You must provide a screen id")
|
||||||
|
id = tohash(id)
|
||||||
|
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
|
||||||
|
|
||||||
|
local screen = screens[id]
|
||||||
|
if screen.proxy then
|
||||||
|
local missing_resources = collectionproxy.missing_resources(screen.proxy)
|
||||||
|
return #missing_resources > 0
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
--- Unload a preloaded monarch screen
|
--- Unload a preloaded monarch screen
|
||||||
-- @param id (string|hash) - Id of the screen to unload
|
-- @param id (string|hash) - Id of the screen to unload
|
||||||
@@ -1361,8 +1376,10 @@ function M.on_post(id, fn_or_url)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local empty_hash = hash("")
|
||||||
|
|
||||||
local function url_to_key(url)
|
local function url_to_key(url)
|
||||||
return (url.socket or hash("")) .. (url.path or hash("")) .. (url.fragment or hash(""))
|
return (url.socket or empty_hash) .. (url.path or empty_hash) .. (url.fragment or empty_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user