Skip to content
This repository has been archived by the owner on Feb 23, 2019. It is now read-only.

Add Resource Module #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add Resource Module #7

wants to merge 3 commits into from

Conversation

s0kil
Copy link

@s0kil s0kil commented Sep 15, 2018

No description provided.

@s0kil
Copy link
Author

s0kil commented Sep 15, 2018

Fixes: mint-lang/mint#92

@gdotdesign
Copy link
Member

Thank you for this pull request! 👍

I didn't know that we can pre-fetch resources programmatically like this 🙂
I did something similar (normal loading of resources) in the mint-codemirror repository:
https://github.com/mint-lang/mint-codemirror/blob/master/assets/asset-loader.js
https://github.com/mint-lang/mint-codemirror/blob/master/source/AssetLoader.mint

I think it would be nice if we could combine them in some way. I have a few suggestions:

  • since we are loading assets and it returns Promise(Never, Void) already, it would make sense to return an actual promise which resolves when the asset is loaded so they could be used in sequence and parallel expressions
  • also it would be nice if the possible errors were handled if the requested resource is not found by the server

Let me know what you think 😄

@s0kil
Copy link
Author

s0kil commented Sep 15, 2018

@gdotdesign That sounds good, I will look into the error handling.
Do you think it should return a promise only when an asset is loaded?
Or also return a promise when an asset is pre-loaded?

@gdotdesign
Copy link
Member

gdotdesign commented Sep 16, 2018

I think they should return somethings like Promise(Resource.Error, Void) for all requests (load and pre-load as well), where Resource.Error is an enum of possible errors.

@s0kil
Copy link
Author

s0kil commented Sep 17, 2018

When preloading resources, there does seem to be a way to catch errors, so far only the onload event works, when a resource is loaded.

For example, let's say you provide a invalid as value to preload, the console gets a warning:
<link rel=preload> must have a valid as value
But onerror never fires, and onload also never fires.

So maybe there could be a bool type: loaded = true | false.
But what would be the timeout of the loaded, since it would never fire if recourse was not loaded?
30-60 seconds seems reasonable.

@gdotdesign
Copy link
Member

I think 30 seconds should be fine.

@@ -1,6 +1,6 @@
module Html {
/*
Returns an empty Html node. It is useful for example if you dont to
Returns an empty Html node. It is useful for example if you dont want to

Choose a reason for hiding this comment

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

Suggested change
Returns an empty Html node. It is useful for example if you dont want to
Returns an empty Html node. It is useful for example if you don't want to

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants