Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(url): sync selected layers state to url #196

Merged
merged 4 commits into from
Nov 15, 2019
Merged

Conversation

KatvonRivia
Copy link
Member

@KatvonRivia KatvonRivia commented Nov 14, 2019

closes #170


export function activeLayersSelector(state: State) {
const {main: mainId, compare: compareId} = selectedLayerIdsSelector(state);
export function activeLayersSelector(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of the selector is somehow misleading. It doesn't necessarily return the active layers, it just returns the layer details for the given layer ids. Maybe "layerDetailsSelector" would make more sense.

const {main: mainId, compare: compareId} = selectedLayerIdsSelector(state);
export function activeLayersSelector(
state: State,
props: {[key: string]: string} | null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type for the props could be more accurate.

{mainLayerId?: string, compareLayerId?: string}

would be nice.

Another nice solution would be to accept only one layer id here and return the layer details for the given id.

return state.layers.details[layerId]

This would make the selector more reusable.
Then we use the selector twice in the component, once with the mainLayerId and once with the compareLayerId.


export function selectedLayersSelector(state: State): SelectedLayerItems {
export function selectedLayersSelector(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here... the name is misleading. The selector doesn't know which layers are selected, it just returns the layers depending on the props passed to the selector.

Maybe you can refactor this similar to the activeLayersSelector

@KatvonRivia KatvonRivia merged commit 82276e4 into develop Nov 15, 2019
@KatvonRivia KatvonRivia deleted the feat/url-state branch November 21, 2019 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store layer in URL
2 participants