effect icon indicating copy to clipboard operation
effect copied to clipboard

From Discord: Issue with Request.tagged and Equal.equals for non-primitive parameters

Open effect-bot opened this issue 1 year ago • 0 comments

Summary

In the above conversation, the user raised an issue with using Request.tagged and Equal.equals for requests that contain non-primitive parameters. It was observed that two requests with equal values are not considered equal according to Equal.equals if they contain non-primitive parameters. This can lead to caching not working for these types of requests.

To address this issue, there are a few best practices to consider:

  1. Use the Data module for internal objects: By using the Data module for non-primitive parameters, you can ensure that they are compared by value rather than by reference. This can help in achieving the desired behavior for caching.

  2. Implement custom Equals for Request objects: Another approach is to manually implement the Equals function for Request objects. This allows you to customize how the objects are compared, taking into account the specific properties that should be considered for equality.

  3. Consider comparing specific properties: In some cases, comparing specific properties, such as an "id" field, may be sufficient for determining equality. This can be a simpler approach, especially for entities where the unique identifier is the most important factor.

Overall, the key takeaway is that when dealing with requests that have non-primitive parameters, it's important to ensure that the equality comparison is implemented correctly to enable caching and other desired behaviors.

Discord thread

https://discord.com/channels/795981131316985866/1214495832246853682

effect-bot avatar Mar 05 '24 09:03 effect-bot