While much of the core functionality of the Aeris WeatherBlox remains unchanged from version 1.0, there have been several naming, setup and architectural changes to the library that you should be aware of when upgrading from version 2.0.
The following guide outlines the major changes you’ll notice when updating your code to use version 2.0 of the WeatherBlox library from 1.0.
Starting with version 2.0, there is no longer a global Aeris
object that you access in order to use the WeatherBlox library. Instead, you’ll create an instance of AerisWeather
configured with your Aeris access keys. You’ll then use this instance for creating views and layouts in your applications.
Refer to our updated Getting Started documentation for more details.
Starting with version 2.0 of the WeatherBlox library, we are now storing each version under its own versioned directory. So the new script and style URLs will be in the format:
http://cdn.aerisapi.com/wxblox/__VERSION__/aeris-wxblox.js
http://cdn.aerisapi.com/wxblox/__VERSION__/aeris-wxblox.css
where __VERSION__
corresponds to the version you want to use. Typically, you’ll always want to be using latest
to ensure that you’re using the most recent version of WeatherBlox and will continue to receive updates and fixes as they are released:
http://cdn.aerisapi.com/wxblox/latest/aeris-wxblox.js
http://cdn.aerisapi.com/wxblox/latest/aeris-wxblox.css
However, you may want to lock your WeatherBlox library to a specific version or revert back to a previous version in the special case that a new bug was introduced in the latest release. Use the major.minor.mini format when requesting a specific version. The following would include the script and stylehsheet tagged as version 2.0.1:
http://cdn.aerisapi.com/wxblox/2.0.1/aeris-wxblox.js
http://cdn.aerisapi.com/wxblox/2.0.1/aeris-wxblox.css
With version 2.0 of the Aeris WeatherBlox library, the setup process is slightly different than that of the 1.0 version. You’ll need to perform the following changes to your 1.0 usage in order to upgrade to 2.0:
Replace the following asset imports:
<link rel="stylesheet" href="https://cdn.aerisapi.com/wxblox/aeris-wxblox.css">
<script src="https://cdn.aerisapi.com/wxblox/aeris-wxblox.min.js"></script>
with:
<link rel="stylesheet" href="http://cdn.aerisapi.com/wxblox/latest/aeris-wxblox.css">
<script src="http://cdn.aerisapi.com/wxblox/latest/aeris-wxblox.js"></script>
There is no longer an Aeris
object in the global scope that you access to use the WeatherBlox library. So replace the following initialization code:
// Configure Aeris API access keys
Aeris.wxblox.setAccess('CLIENT_ID', 'CLIENT_SECRET');
with:
// Configure Aeris API access keys
const aeris = new AerisWeather('CLIENT_ID', 'CLIENT_SECRET');
Starting with 2.0, you’ll now create an instance of the library configured with your Aeris access keys that you will then use to create views and layouts from.
In step 2 you set up and configured an instance of AerisWeather
for your account. You’ll now need to access the library’s views, layouts and utilies from this instance instead of the global Aeris
object that was used in 1.0.
In your Javascript code, replace all instances of:
Aeris.wxblox.
with:
aeris.wxblox.
Make sure you’re accessing your aeris
instance only after it has been instantiated as described in step 2.
For instance, in version 1.0 of the library, you would create a Forecast view using the following setup code:
Aeris.wxblox.setAccess('CLIENT_ID', 'CLIENT_SECRET');
const localForecast = new Aeris.wxblox.views.Forecast('#local-forecast');
localForecast.load({
p: ':auto',
limit: 5
});
The same setup updated for version 2.0 would be:
const aeris = new AerisWeather('CLIENT_ID', 'CLIENT_SECRET');
const localForecast = new aeris.wxblox.views.Forecast('#local-forecast');
localForecast.load({
p: ':auto',
limit: 5
});
That’s it, you’re now fully converted over to version 2.0!
Fortunately, the changes required for users working with WeatherBlox using the API method are minimal. While we’ve ensured that your WeatherBlox setup will continue to work without performing the following changes, it’s best to take care of them now to account for 1.x-related setup deprecations in the future.
First, you’ll want to load in the new version of the library. So replace the following include:
<script src="http://cdn.aerisapi.com/wxblox/aeris-wxblox.js"></script>
with:
<script src="http://cdn.aerisapi.com/wxblox/latest/aeris-wxblox.js"></script>
Also, in version 1.x of the library, you had to also include a second script when using the API method to handle the library’s Javascript interface components. You no longer need to load this script with version 2.0 as it’s built into the core library script.
So you can remove the following script include:
<script src="https://cdn.aerisapi.com/wxblox/aeris-wxblox-ui.min.js"></script>
That’s it, you’re now fully converted over to version 2.0!
Last modified: July 15, 2019