Errai: The browser as a platform

Wednesday, May 24, 2017

Errai 4.0.0.Final released!

Today I'm thrilled to announce that Errai 4.0.0.Final has been released!

At a glance, here are the big changes from Errai 3 to 4:
  • Uses GWT 2.8.0 and WildFly 10 for Super Dev Mode
  • Has a new Errai IoC container supporting incremental code regeneration, and greater compliance with CDI
  • Has advanced JS Interop support, including dependency injection of native JavaScript objects, and templating and data-binding with JS Interop wrappers of DOM elements and web components
  • Has message bus enhancements (better clustering support and CSRF protection)
All of these changes have been discussed in previous blog posts. Nonetheless, in this post I will summarise these changes with links to the more detailed descriptions.

New Errai IoC Container

Errai 4 has a new IoC container, that supports incremental regeneration of code. The main benefit of this is to improve the performance of refreshing during Super Dev Mode. But this rewrite also allows for the possibility of migrating to annotation processors for all code generation in a future release.

The new IoC container also more closely aligns with CDI:
  • @ApplicationScoped beans must be proxiable, and are lazily loaded like in Weld
  • @Singleton is a "pseudo-scope": it need not be proxiable but cannot be part of a circular injection
  • @Typed annotation is supported
In some cases, beans may be resolved slightly differently than in Errai 3. Our upgrade guide highlights some important "gotchas" to look out for when upgrading to Errai 4.

Advanced JS Interop Support

The overarching theme of Errai 4 is working directly with JavaScript APIs and the DOM via JS Interop. If you don't already know about JS Interop, I encourage you to watch the first half of this talk by Daniel Kurka at GWTCon.

Here are the ways in which you can use JS Interop with Errai 4:
  • Use JS Interop interfaces for DOM elements or web components as @DataFields in @Templated components
  • Use JS Interop interfaces for DOM elements or web components as @Bound UI components with Errai data-binding
  • Inject JavaScript objects into your application like normal GWT/Java objects
You can read more about Errai 4 JS Interop support here and here, or view examples in the Errai Tutorial.

Message Bus Enhancements

The Errai message bus has received some love in Errai 4, with fixes that improve fail-over behaviour in clustered setups, and optional built-in CSRF protection.

Both of these are described briefly in this blog post.

Thanks to the Community

I'd like to end by thanking everyone in the Errai community who contributed to the quality of this release, through pull requests with new features and reports of important issues in our beta and candidate releases. In particular, the Errai JS Interop support was greatly improved by the important feedback from our community.

Until the next time, happy coding!