Creating Custom Plugins with Fusion.js, Uber’s Open Source Web Framework

Carsten Jacobsen
11 min readadvanced
--
View Original

Overview

This article provides a comprehensive guide on creating custom plugins with Fusion.js, Uber's open-source web framework. It covers the core concepts of plugins, their architecture, and practical implementation through a temperature conversion application.

What You'll Learn

1

How to create a custom plugin in Fusion.js

2

Why dependency injection is beneficial in plugin architecture

3

How to implement middleware for rendering results in a Fusion.js application

Key Questions Answered

What are the core concepts of plugins in Fusion.js?
Plugins in Fusion.js encapsulate functions that can be reused throughout the application, such as logging, translations, and data source integrations. They allow developers to build complex applications without writing their own plugins, leveraging existing functionalities.
How does dependency injection work in Fusion.js plugins?
Dependency injection in Fusion.js allows plugins to expose well-defined APIs as services, which can be injected into other plugins. This architecture simplifies the inclusion of libraries and promotes code reuse across the application.
What is the process for creating a temperature conversion application using Fusion.js?
To create a temperature conversion application, developers must set up a Fusion.js application, create a converter plugin that provides conversion services, and render the results using a component. The application can then be registered and run to demonstrate the functionality.

Technologies & Tools

Some links below are affiliate links. We may earn a commission if you make a purchase.

Framework
Fusion.js
Used as the main framework for building the application and managing plugins.
Frontend
React
Used for building the user interface components within the Fusion.js application.

Key Actionable Insights

1
Utilize plugins to encapsulate common functionalities across your application.
By encapsulating features like logging or data fetching in plugins, you can maintain cleaner code and improve reusability, making it easier to manage and update functionalities.
2
Leverage dependency injection to enhance modularity in your applications.
Dependency injection allows you to inject only the necessary services into your components, reducing the overall size of your application and improving performance.
3
Implement middleware for rendering results effectively.
Middleware can be used to manage how results are rendered in the application, allowing for more flexible and maintainable code structures.

Common Pitfalls

1
Neglecting to properly manage dependencies can lead to bloated application sizes.
When dependencies are not injected where needed, it can result in including unnecessary code in the browser bundles, impacting performance.

Related Concepts

Plugin Architecture
Dependency Injection
Middleware In Web Applications