Code Monkey home page Code Monkey logo

fusion-plugin-universal-events's Issues

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.

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);
    }

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.