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

Performance: unwanted executions of transform() function #30

Open
red-meadow opened this issue Jun 8, 2018 · 0 comments
Open

Performance: unwanted executions of transform() function #30

red-meadow opened this issue Jun 8, 2018 · 0 comments

Comments

@red-meadow
Copy link

red-meadow commented Jun 8, 2018

Hello!

I use collections/cursors with defined transform() function to transform raw documents to class instances. Normally, this function is executed when a document is fetched for the 1st time or updated. But with vue-meteor-tracker it's re-executed for all matching documents if one of them has been changed. Please, take a look at the code:

<template>
  <main>
    <div v-for="note in notes">
      {{ note.text }}
    </div>
  </main>
</template>
<script>
import Notes from '/imports/Notes'

export default {
  meteor:  {
    $subscribe: {
      'notes.all': []
    },
    notes() {
      return Notes.find({}, {
        transform(note) {
          console.log('transformed');
          return note
        }
      })
    }
  }
}
</script>
// server.js
create7Notes()

// later
updateSingleNote()  //  => 7 'transformed' messages in the browser

As you see, each note is transformed again even if it wasn't updated. That might be a problem for the large datasets. I tried the same scenario in Blaze using {{#each .. in}} helper and everything works as expected: transfom() is re-executed only for the updated document.

Is this an expected behavior for vue-meteor? Is there a way to change it?

Thank you in advance!

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

1 participant