Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PushUpdates is there a limitation (Does it work with arrays)? #183

Closed
undecided2013 opened this issue Feb 25, 2019 · 3 comments
Closed

PushUpdates is there a limitation (Does it work with arrays)? #183

undecided2013 opened this issue Feb 25, 2019 · 3 comments

Comments

@undecided2013
Copy link

I copied the simple hello world example and I am attempting to return an array of values back
public class TestStrm : BaseVM
{
// This is the property that I want to stream to client
public DataElement[] dataElements => GetBufferArray();
private DataElement[] GetBufferArray()
{
return _buffer.ToArray();
}

        _timer = new Timer(state =>
        {
            Changed(nameof(dataElements ));
            PushUpdates();
        }, null, 0, 1000);

I can see the array being full with data but nothing arrives at the client. I do break in the browser debugger and it stops at the population of the dataElements variable but length is zero.
Does this work with arrays?

p.s. If I replace
return _buffer.ToArray();
with
return new DataElement[100] ;

I do get back the empty array.

p.p.s. I see the timer updating the page.

@dsuryd
Copy link
Owner

dsuryd commented Feb 25, 2019

It works with array, as can be seen in the live chart example. If there's problem, likely cause is the array item type isn't JSON serializable.

@undecided2013
Copy link
Author

You are correct sir. Switching the array to string allowed it to work. The bizarre thing is that I am using Newtonsoft to serialize and deserialize the data that was going into that array so I do not understand why if newtonsoft can do it in my code, the same json would fail to make it to the client. I did see that you are also using Newtonsoft for the json serialization to the client. Do you have any idea why that would be the case? Thx

@dsuryd
Copy link
Owner

dsuryd commented Feb 25, 2019

Do you see any exception in your VS debug output? Could be the difference in the serialization settings, which you can control (see #105).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants