Skip to content

improve RPC functions that are depending on Vite RPC #213

@LoTwT

Description

@LoTwT

description

Thank @webfansplz for the original version in #195. I mimic the codes in the #212.

After the #212 has been approved, two events will depend on Vite RPC. They are designed to trigger changes reactively in the client.

However, I think some problems need to be improved.

problems

  • The default value of the function is an anonymous function everywhere. Maybe a const NOOP = () => {} is more appropriate.
  • The same RPC function name and type between server-to-client and client-to-server. What about designing a rule to define RPC function names clearly? It will make anyone who uses the RPC functions more easily comprehend.
  • Manually copied codes will be fragile. What about designing an RPC function factory to easily create an RPC function with safe types and better-designed names?

new feature

Adding a return callback to remove the client-designed callback itself since the client-designed callbacks will be tracked in an array and the off will remove all callbacks by setting the length of the array to zero.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions