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

Chained ray() methods are not always followed. #267

Closed
TWithers opened this issue Mar 27, 2024 · 1 comment
Closed

Chained ray() methods are not always followed. #267

TWithers opened this issue Mar 27, 2024 · 1 comment

Comments

@TWithers
Copy link

I have a call that looks like ray().toJson(jsonValue).color(componentColor).label(componentName) that gets called fairly often while on a page. The problem is that the snippet of code will initiate 3 requests to the ray server instead of 1. This causes some sort of race condition which means that the label or color may not apply to the initial payload. It does seem to work about 80% of the time, but when I am issuing this call quickly back to back for different components, it will likely fail.

The solution I have implemented is to tap into the sending_payload_callback setting and attach a new ColorPayload and a LabelPayload to the initial payload. As far as I can tell this works, but it is a painful work around. Perhaps there could be a new method called chain() which would allow me to do something like ray().chain( (ray) => ray.toJson(jsonValue).color(componentColor).label(componentName) ).

Another issue was that the Payload objects were not exported, so I couldn't import them inside vite. I ended up copying the code from the esm module to create the Payload classes.

@patinthehat
Copy link
Member

@TWithers Thanks for the bug report! I implemented your suggestion for chain() in version 2.1.0.

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

No branches or pull requests

2 participants