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

Reactive src prop #18

Open
timyhac opened this issue May 14, 2019 · 6 comments
Open

Reactive src prop #18

timyhac opened this issue May 14, 2019 · 6 comments
Assignees

Comments

@timyhac
Copy link

timyhac commented May 14, 2019

Is your feature request related to a problem? Please describe.
I need to dynamically change the data that is being viewed in this component. I would like the src property to be reactive.

Describe the solution you'd like
Set a watcher on the src property, which triggers a re-initialization of the component.

Describe alternatives you've considered
My current workaround is to set a :key property on the pdf component, and when updating the src data I also modify the key (by incrementing it).

Additional context
I am using TypeArrays to feed data to this component. My :src property looks something like this:

<pdf :src="pdfObject" :key="forceReRenderKey"></pdf>
computed: {
  pdfObject: function(){
    const attachmentIndex = <<<dynamic value>>>;
    const newDataObject = {
      data: new Uint8Array(this.$store.getters.attachments[attachmentIndex].content) // content is a TypedArray
    };
    this.forceReRenderKey++;
    return newDataObject;
  }
}
@morphace
Copy link

morphace commented Jun 9, 2019

+1

@ramanangru
Copy link
Contributor

+1

@floreasy
Copy link

floreasy commented Jun 3, 2020

Thanks +1

@inakineitor
Copy link

+1

@juan-carvajal
Copy link

Instant fix, thanks

@KrisHedges
Copy link

Just for posterity and others who may find this seeking help you can also use this dynamic key technique in the v-for usage like so...

    <pdf
      :src="pdfdata"
      v-for="i in numPages"
      :key="i + dynamicKey"
      :id="i"
      :page="i"
      @loading="loaded"
    />

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

8 participants