Giter Site home page Giter Site logo

fusion-plugin-universal-events's Introduction

Modern framework for fast, powerful React apps

Build status fusion-core Downloads

What is it?

fu·sionnoun

The process or result of joining two or more things together to form a single entity.

Fusion.js, Uber’s open source universal web framework, represents the fusion of the client and the server. It's geared for server-side rendering out of the box, and its plugin-driven architecture allows for complex frontend and backend logic to be encapsulated in a single plugin:

import App from 'fusion-react';
import Router from 'fusion-plugin-react-router';

export default () => {
  const app = new App(<div>...</div>);

  /*
  One line of code sets up everything you need for routing:
  - Server rendering
  - React Providers on both server and browser
  - Bundle splitting integration
  - Hot module reloading support
  */
  app.register(Router);

  return app;
}

We initially built Fusion.js to make our own websites easier to maintain, but were so impressed with the benefits that we decided to offer it to the community as an open source project!

Try it out

If you're interested in giving Fusion.js a shot, Overview and Core Concepts are great places to start.

Contributing

This is a monorepo of all open source Fusion.js packages maintained using Yarn v2. Take a look at CONTRIBUTING.md for info on how to develop in this repo.

License

MIT

fusion-plugin-universal-events's People

Contributors

alexmsmithca avatar angus-c avatar dennisgl avatar ganemone avatar kevingrandon avatar ksheedlo avatar lhorie avatar nadiia avatar renovate-bot avatar renovate[bot] avatar rtsao avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fusion-plugin-universal-events's Issues

Native fetch throws errors

Type of issue

Bug

Description

If you follow the getting started guide and register fetch via the window,

// ...
  __BROWSER__ && app.register(FetchToken, window.fetch)

this will fail in chrome with “Uncaught TypeError: Illegal invocation”, as the fetch is later executed during flush in the context of current object.

For this to work properly, it must be executed in the context of window, https://stackoverflow.com/a/10743608/1403990

A naive change is to modify the constructor of the UniversalEmitter:

this.fetch = fetch; // from
this.fetch = fetch.bind(window); // to

but i'm not sure how this would play out in older browsers, different fetch implementations, etc.

One other thing. This bug, is unreported to devs as the try catch surrounding the call to the fetch, swallows the error.

 try {
      const res = await this.fetch('/_events', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json',
        },
        body: JSON.stringify({items}),
      });

      if (!res.ok) {
        // sending failed so put the logs back into storage
        this.storage.addToStart(...items);
      }
    } catch (e) {
      // There should be some noise here during development
     // that this branch is being executed...
      this.storage.addToStart(...items);
    }

Add Token dependencies to readme

Problem/Rationale

Documentation regarding Fusion API is out of date given recent changes to leverage new Dependency Injection architecture.

Solution/Change/Deliverable

Update documentation

Allow server-side global emission with ctx

Example:
https://github.com/fusionjs/fusion-plugin-browser-performance-emitter/blob/54c21ae45a99a2719608873d13585b467ef668dd/src/server.js#L28-L31

  const emitter = EventEmitter.of();
  emitter.on('browser-performance-emitter:stats:browser-only', (e, ctx) => {
    emitter.emit('browser-performance-emitter:stats', mapPerfEvent(e), ctx);
  });

Currently, ctx is not passed in handleEvent() when emits from a global emitter service, which prevents plugin listeners on server-side to re-emit browser events with ctx

emit(type, payload, ctx) was the contract agreed upon, therefore we should still support it until a proper alternative.

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Preset name not found within published preset config (monorepo:angularmaterial). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Support * event type for handlers and mappers

It can be useful to map or handle all events. For example,
an event logger that logs all events. We can support this
through an interface such as:

events.on('*', payload => {});
events.map('*', payload => {});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.