Some doubts I have:
Namespaces
This package should have a namespace called source
. Each package should set its own namespace, and so it has to “export” it somehow. I don’t know how is the best way to do that.
Looking at the Overmind examples, it’s the root store who is giving names to each namespace.
Typing
When accessing other namespaces, for example, deriving a property using state from a different domain, it’s not clear to me where types come from. In the code below, imagine that selectedEntity
is a derived prop (defined in the router
package) that returns an object of type Entity
(defined in the source
package). I don’t know if implicit typing will work in this case or we need to import the external types explicitly.
// should external types be imported explicitly?
import { Entity } from '@frontity/wp-source';
export const state: State = {
selectedItem: { type: 'post', id: 60 },
selectedEntity: (state, rootState): Entity => {
const { type, id } = state.selectedItem;
return rootState.source.getEntity({ type, id });
}
}
In that case, I don’t know how it would work either, especially considering that in-use packages are not known before runtime. Or is that going to be specified in the settings?
Maybe I’m thinking too much about this because of my little knowledge about TypeScript…