jFactory > Reference > Traits > TraitFetch
TraitFetch
Registers fetch()
requests that will be automatically stopped and removed at Remove Phase.
This uses JFactoryFetch
which inherits from JFactoryPromise
, allowing Request Abortion and Promise Chain Expiration.
Registry
myComponent.$.requests
Injected Methods
$fetch(registryId {string}, url {string}, fetchOptions {object})
Returns: JFactoryFetch
resolved with the Fetch Response.
See also $fetchText()
and $fetchJSON()
Defers current Phase: This method registers a Task that blocks the resolution of the current Phase (if any) until the whole Task chain (including subpromises) is resolved.
Auto completed: The promise chain is completed and expired as soon as all subpromises are resolved. This behavior can be disabled by setting
anyPromiseOfTheChain.$chain.chainConfig.chainAutoComplete = false
before the promise chain is completed.
Auto removed: This Subscription is removed as soon as its Promise Chain is completed.
myComponent.$fetch("myFetch", "asset.html", {
cache : 'no-cache'
})
.then(fetchResponse => {})
$fetchText(registryId {string}, url {string}, fetchOptions {object})
Returns: String
Same as $fetch()
but resolved as String.
$fetchJSON(registryId {string}, url {string}, fetchOptions {object})
Returns: Object
Same as $fetch()
but resolved as JSON Object.
$fetchRemove(registryId {string}, reason {string} = "$fetchRemove()")
Expires and removes the fetch registered with the key registryId
previously created by $fetch()
. An optional reason can be given for debugging the aborted Promise Chain.
$fetchRemoveAll(removePhase)
(Automatically called at Remove Phase)
Expires and removes any JFactoryFetch
previously created by $fetch()
if their Remove Phase match the given removePhase
.