2019-06-01 net

(Brent) #1

This process might sound somewhat
complex but works really well in practice.
Furthermore, its browser support is
exceptionally wide.


Push API
https://developer.mozilla.org/en-US/
docs/Web/API/Push_API
Pulling is a classic
anti-pattern in the
process computer
space – sadly, web
developers had
little choice. The
Push API provides a way around the problem.
It is based on a traditional push system,
where data is actively driven from the server
side rather than by client-side requests.
In short, not only does this prevent
users’ devices having to regularly issue
pull requests to check whether new data is
waiting for them but it also allows sites and
apps to issue push notifications to mobiles
and desktops.
Sadly, such features tend to invite abuse by
unscrupulous developers. Due to that, almost
all vendors tend to use a browser-based
dialogue to get the user to agree to receiving
notifications. Another important issue
developers need to keep in mind involves
quotas – most, if not all browsers limit the
amount of messages that can be delivered at
any given point in time.


Web Audio API
https://w w w.w 3.org /TR /webaudio/
In bygone days,
keeping a MIDI file
playing in the
background was a
given. Some law
firms in Austria
went so far as to annoy their visitors with an
orchestra’s worth of classical music.
The new Web Audio API, which currently is
a W3C candidate, has nothing to do with this
traditional source of nuisances. It, instead,
provides a modern graph-based audio output
API. This means that you set up a chain of
filters, data sources and output sinks such as
headphones or speakers. Once done, these
are then fed with dynamically generated


or locally stored content, resulting in a
completely custom experience.
In theory, you could also use this API to
simply play back MP3 or Ogg Vorbis files –
a valid strategy but one that can be more
efficiently delivered with the HTML5 <audio>
element. The API can, instead, play out its
strengths whenever you need to modify
the output; the system provides a wide
variety of nodes such as ConvolverNode and
WaveShaperNode, which are used to add
reverb and distortion to sound respectively.
Another area where the API excels is
creating experiences that react to the music.
If you’re working on a 2D or 3D project, you
can feed variables from the Web Audio API
into the canvas or WebGL APIs respectively,
creating visualisations or games that react to
factors like the audio’s frequency or volume.

WebVR API
https://developer.mozilla.org/en-US/
docs/Web/API/WebVR_API
While Microsoft’s
introduction of the
Kinect sensor was
ill-fated, virtual-
reality technologies
are here to stay.
Mozilla’s WebVR API – also supported by
Microsoft Edge – lets your web apps and sites
break the fourth wall.
Sadly, the API is just part of what’s needed
for a complete VR scene. In particular, the
API limits itself to providing a set of classes
enumerating displays and position sensors
connected to your user’s workstation or
laptop. Actually getting something on-screen
requires the use of additional APIs dedicated
to the creation of three-dimensional scenes
optimised for virtual reality.
One particularly useful candidate comes
from the company behind the WebVR API –
Mozilla’s A-Frame-API (see https://aframe.
io/) lets you create virtual reality scenes. Do,
however, keep in mind that the development
of such scenes is a completely different
animal to the development work done on
websites – yours truly’s painful experience
shows that some developers will have a
very hard time adapting their brain to the
workflow required for the creation of three-
dimensional objects.

GETTING


ACCESS TO


A USER’S


LOCATION IS


PARAMOUNT


IF MANY


BUSINESS


PROCESSES


ARE TO WORK


19 groundbreaking APIs

Free download pdf