Redux doesn't like non-serializable values in the store (or in actions.) But our entities use Moment for dates. The entities come from the API as timestamp strings, but this is problematic because 1) strings are less convenient for date comparison/formatting, and 2) this type is incompatible with the server-side entity, making cross-platform helper methods more complicated (would have to type them to handle objects having either strings or Moments at each time field.)
For now, we are starting to convert our entity timestamps to Moment objects in entities.js. This provides convenience and type compatibility. But it violates Redux's rule, so I'm worried that it's not a viable long-term solution.
This is an approach of typing entities in the client as using strings for time. But it is problematic because now methods accepting UrlLocator don't accept UrlLocatorView.
export type ReplaceDeep<T, From, To> = T extends From
? To
: T extends object
? { [K in keyof T]: ReplaceDeep<T[K], From, To> }
: T;
export type UrlLocatorView = ReplaceDeep<UrlLocatorOut, Moment, string> & {
/** A key uniquely identifying a url locator relative to others. */
key: string;
};
Redux doesn't like non-serializable values in the store (or in actions.) But our entities use Moment for dates. The entities come from the API as timestamp strings, but this is problematic because 1) strings are less convenient for date comparison/formatting, and 2) this type is incompatible with the server-side entity, making cross-platform helper methods more complicated (would have to type them to handle objects having either strings or Moments at each time field.)
For now, we are starting to convert our entity timestamps to Moment objects in entities.js. This provides convenience and type compatibility. But it violates Redux's rule, so I'm worried that it's not a viable long-term solution.
This is an approach of typing entities in the client as using strings for time. But it is problematic because now methods accepting
UrlLocator
don't acceptUrlLocatorView
.Possible solutions:
Other notes: