Skip to content

v9.0.0

Latest
Compare
Choose a tag to compare
@cat394 cat394 released this 28 Oct 03:30
· 5 commits to main since this release

What's Changed?

  • Removal of create_link_generator Function

    The create_link_generator function has been removed and replaced by a new function, link_generator. The link_generator function now accepts a route_config object, internally calls the flatten_route_config function, and transforms it into a Map. This approach allows for high-speed link generation through the returned link function.

    const route_config = {
      products: {
        path: "/products",
      },
    } as const satisfies RouteConfig;
    
    const link = link_generator(route_config);
    
    link("products"); // => '/products'
  • Deprecation of flatten_route_config Function

    The flatten_route_config function was previously public because it enabled easy visual representation of the flattened types while generating the link function in create_link_generator. It was also meant to save the effort of creating specific type definitions to obtain the flattened types. However, this restricted the ability to make breaking changes to the flatten_route_config function. Since the link_generator function now calls this internally in version 9, there is no longer a need to keep it public.

  • Modification of link Function API to Accept Any Number of Query Objects

    The previous link function had a limitation where multiple identical query parameters could not be generated. This has been resolved in version 9, and the link function has been modified to accept any number of query objects starting from the third argument.

    const route_config = {
      products: {
        path: "/products?color&size",
      }
    } as const satisfies RouteConfig;
    
    const link = link_generator(route_config);
    
    link('products', undefined, { color: 'red' }, { color: 'blue' }, { color: 'green', size: 'small' }); 
    // => /products?color=red&color=blue&color=green&size=small
  • Improved Code Readability

    Variable and function names used internally have been clarified to enhance code readability.