Promises
BellJs now supports promises, this means that you can show a loading layout while loading a request for a promise.
To use promises in Bell you just have to use the promises method of that instance. Let’s see an example:
The first thing we do is create a promise in JavaScript and the states that the promise will have are: pending
, success
and error
.
Then we create an instance of Bell
, we pass it a title
that will serve as a placeholder and the promise
type.
Finally we use the promise
method and we pass it the states and the promise as parameters:
And that’s it, you can now use promises in BellJs
with fetch
or others.