JavaScript Update reactive variable from event shiny update reactive variable,r shiny update reactive variable,shiny

I'm using

Template.uploadFile.events({
  'change .set-file': function ( event, template ) {
    var file = event.currentTarget.files[0];

    [...]
  }
});

when uploading a file.

I want to read every row in the file and insert each row as a document in a collection.

The problem is that I want to reactively show the user how many rows has been created.

First I need to set the number of lines in the file as a variable. I have to set the variable inside my event since I only know the number of lines after the file has been read (i.e. the event has been fired).

I guess I have to do something like

Template.uploadFile.helpers( {
  numRows: function () {
    return ?;
  },
  numInsertedRows: function () {
    return ?;
  },
} );

Number of inserted rows could just be the number of documents in my collection; however, I guess it's quite memory demanding to read from the collection at the same time as I'm inserting into the collection.

So I think it's better to just use plain variables, since all the information should be available without asking the database.

I have a loop

rowsInFile.forEach( function ( row ) {
    // add 1 to number of inserted rows
} );

but that loop should also change the one of the reactive variables.

I guess I should use a reactive variable. Am I right? Is it the most memory efficient way to do it?

Answer:1

I have a screen in my app that has a "in between" content. This content is too long for the Iphone 5-8, but just one screen for the Iphone 8S-XS Max. To fix it, I've put on a simple ScrollView, ...

I have a screen in my app that has a "in between" content. This content is too long for the Iphone 5-8, but just one screen for the Iphone 8S-XS Max. To fix it, I've put on a simple ScrollView, ...

  1. react native scrollview fill height
  2. react native scrollview full screen

I am working on an application that uses angular js UI grid. But as and when I keep using my application, it keeps adding up to the memory without releasing the dom objects. I have created a sample ...

I am working on an application that uses angular js UI grid. But as and when I keep using my application, it keeps adding up to the memory without releasing the dom objects. I have created a sample ...

  1. ag-grid angular memory leak
  2. angularjs ui grid memory leak

I need to transfer state of a component to its parent component, but I don't need to transfer all fields. What I currently do: submitHandler = (e) => { e.preventDefault(); const ...

I need to transfer state of a component to its parent component, but I don't need to transfer all fields. What I currently do: submitHandler = (e) => { e.preventDefault(); const ...

  1. copy state object react
  2. copy object state
  3. vuex copy state object
  4. reactjs copy state object
  5. redux copy state object
  6. python copy object state

I have an svg circle element with coordinate attribute as below: <circle id="c1" class="area" cx="440" cy="415" r="75"></circle> I would like to generate some random points within the ...

I have an svg circle element with coordinate attribute as below: <circle id="c1" class="area" cx="440" cy="415" r="75"></circle> I would like to generate some random points within the ...

  1. generate random points in a circle
  2. generate random points within a polygon
  3. generate random points in a circle python
  4. generate random points python
  5. generate random points in a circle matlab
  6. generate random points within a polygon python
  7. generate random points in r
  8. generate random points arcgis
  9. generate random points within a polygon r
  10. generate random points arcmap
  11. generate random points matlab
  12. generate random points on a plane
  13. generate random points in a rectangle python
  14. generate random points with minimum distance
  15. generate random points in a square matlab
  16. generate random points on a sphere
  17. generate random points in ellipse
  18. generate random points in a rectangle matlab
  19. generate random points qgis
  20. generate random points within a polygon qgis