Giter Club home page Giter Club logo

Comments (4)

olofd avatar olofd commented on May 30, 2024

Nice find! And very good reporting. I do undertand the issue.

Do you have any code that fixes the problem? Anything you can post here?
Otherwise you could maybe post a reproduce senario or something?

Olof

from react-native-signalr.

boliveira avatar boliveira commented on May 30, 2024

The way I solved it was to move the line const events = subject.events || {}; to the inside of every emulated jquery function (unbind, bind, triggerhandler) like this:

`unbind(event, handler) {
const events = subject.events || {};
let handlers = events[event] || [];

  if (handler) {
    const idx = handlers.indexOf(handler);
    if (idx !== -1) {
      handlers.splice(idx, 1);
    }
  } else {
    handlers = [];
  }

  events[event] = handlers;
  subject.events = events;
},
bind(event, handler) {
  const events = subject.events || {};
  const current = events[event] || [];
  events[event] = current.concat(handler)
  subject.events = events;
},
triggerHandler(event, args) {
  const events = subject.events || {};
  const handlers = events[event] || [];
  handlers.forEach(fn => {
    if (args === undefined) {
      args = { type: event };
    }
    if (!Array.isArray(args)) {
      args = [args];
    }
    if (args && args[0] && args[0].type === undefined) {
      args = [{
        type: event
      }].concat(args || []);
    } else {
      args = args || [];
    }

    fn.apply(this, args);
  });
}`

After these changes, everything worked just fine.

from react-native-signalr.

olofd avatar olofd commented on May 30, 2024

Ah! Great, than I understood you correctly.
I did a change here last night before pushing the new version.
I did not do any difference for basic functionality, so I included what I thought might work.
Can you take a look here:

https://github.com/olofd/react-native-signalr/blob/master/src/jquery-function.js#L16

And test out the new version on npm that the problem is solved?

from react-native-signalr.

boliveira avatar boliveira commented on May 30, 2024

Hi again :)

Unfortunately with the new version I have another error when connecting to SignalR: "method GET must not have a request body"

I traced it to this line in ajax.js

request.send(options.data && qs(options.data));

It seems options.data is an empty object and it's always true, so it will try to send an empty body, even when there is no body to be sent.

If I set options.data = null before this call, it works correctly.

Can you check this out? Thanks for the work!

from react-native-signalr.

Related Issues (20)

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.