Giter Club home page Giter Club logo

Comments (9)

olofd avatar olofd commented on May 29, 2024

Hmm, I'll look into this tonight!

from react-native-signalr.

olofd avatar olofd commented on May 29, 2024

@chris-gregg Sry for taking such a long time before looking at this. But it think that what you are receiving in the done-callback is correct. If you want to receive the actual message sent from the server you should set up a listener before calling invoke like this:

        proxy.on('responseFromServer', (response) => {
           console.log("FROM SERVER", response);
        });
        let messagePromise = proxy.invoke('messageToServer', 'hej');
        messagePromise.done((response) => {
            console.log ("response", response');
        }).fail(function (error) {
            console.log('Invocation of NewContosoChatMessage failed. Error: ' + error);
        });

I have not looked at if the signalr-client used in a browser does the same, but I expect it does. The done for the message is only a status about that particular message.

I will closed this for now.

from react-native-signalr.

chrisgregg avatar chrisgregg commented on May 29, 2024

Hey @olofd, thanks for taking a look. With SignalR you can receive data from the server via a listener/callback as you suggested, but should also be able to access a response from the server via the promise.

I was going to take a look and submit a pull request, but noticed in your last commit that you actually fixed the problem! Looks like the issue was that resolveWith was originally returning the proxy, and not the data (response).

So I can now do this, and successfully retrieve the response:

let messagePromise = proxy.invoke('messageToServer', 'hey');
messagePromise.then((response) => {
     console.log ('response', response);
}).fail(function (error) {
     console.log('Invocation of NewContosoChatMessage failed. Error: ' + error);
});

Thanks again!

from react-native-signalr.

olofd avatar olofd commented on May 29, 2024

ah! Great! Sry for the incorrect answer before! Let me know if there are any other issues with the lib!

from react-native-signalr.

chrisgregg avatar chrisgregg commented on May 29, 2024

Will do, looking forward to using this!

from react-native-signalr.

olofd avatar olofd commented on May 29, 2024

@chris-gregg Can you take a look at this:
#2

I think there should be an apply there, elsewise I get my data wrapped in an array.
Have you experienced this?

from react-native-signalr.

chrisgregg avatar chrisgregg commented on May 29, 2024

Yeah, you're right. I'm seeing the response encapsulated in an array too.

from react-native-signalr.

olofd avatar olofd commented on May 29, 2024

Great! Thanks for the confirmation. I'll merge and release a new version then.

from react-native-signalr.

olofd avatar olofd commented on May 29, 2024

Release 0.0.6

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.