roundupapp / vue-plaid-link

Easy to use Vue component for Plaid Link
MIT License
31 stars 7 forks source link

Reactive token value #4

Open damonjanis opened 5 years ago

damonjanis commented 5 years ago

When I pass a dynamic token into the component it doesn't stick. If I'm understanding the code, it looks like the token is applied when the Plaid Link script is loaded, and then everything is static.

Would it be possible to make the token reactive?

pushchris commented 5 years ago

@damonjanis it should be possible. Would have to do some research to see if Plaid allows you to switch that information from their class after its instantiated, otherwise it would involve destroying the Plaid object and recreating it whenever one of the parameters changes. Not the most elegant solution, but should handle what you are looking for. Schedule is unfortunately busy currently but will try to give it a gander in the next week or so.

damonjanis commented 5 years ago

Thanks @pushchris, I so appreciate what you've done with this component and making it available.

I figured out a hack that works without requiring a change to the component. And it might indicate the Plaid object can be reinstantiated.

PlaidLink is created with a ref like this:

<PlaidLink ref="plaidLinkRef" ...> </PlaidLink>

Then whenever the token needs to change it calls onScriptLoaded and handleOnClick to reload the Plaid Link object like this:

this.$refs.plaidLinkRef.onScriptLoaded() this.$refs.plaidLinkRef.handleOnClick()

The script reloads with the new token set and the Plaid Link object goes from there.