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: add layerAttributes to addLayer and refactor updateLayer #45

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Not released
- Remove OAuthLogin component (extracted to the template project) [#44](https://github.com/CartoDB/carto-react-lib/pull/44)
- Add layerAttributes to addLayer and refactor updateLayer to use same destructuring approach [#45](https://github.com/CartoDB/carto-react-lib/pull/45)

## 1.0.0-beta7 (2020-12-04)
- Add meta value example to List component story [#31](https://github.com/CartoDB/carto-react-lib/pull/31)
Expand Down
5 changes: 3 additions & 2 deletions docs/api-reference/redux.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,22 @@ Action to add a Layer to the store
| --- | --- | --- |
| id | <code>string</code> | unique id for the layer |
| source | <code>string</code> | id of the source of the layer |
| layerAttributes | <code>object</code> | (optional) custom attributes to pass to the layer |

### updateLayer
Action to update a Layer in the store

| Param | Type | Description |
| --- | --- | --- |
| id | <code>string</code> | unique id for the layer |
| layerAttributes | <code>object</code> | layer attributes to update (source, or other custom attributes) |
| layerAttributes | <code>object</code> | custom attributes to pass to the layer |

### removeLayer
Action to remove a layer from the store

| Param | Type | Description |
| --- | --- | --- |
| layerId | <code>string</code> | id of the layer to remove |
| id | <code>string</code> | id of the layer to remove |

### setBaseMap
Action to set a basemap
Expand Down
9 changes: 5 additions & 4 deletions src/redux/cartoSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,22 @@ export const removeSource = (sourceId) => ({ type: 'carto/removeSource', payload
* Action to add a Layer to the store
* @param {string} id - unique id for the layer
* @param {string} source - id of the source of the layer
* @param {object} layerAttributes - custom attributes to pass to the layer
*/
export const addLayer = ({id, source}) => ({ type: 'carto/addLayer', payload: {id, source} });
export const addLayer = ({id, source, layerAttributes = {}}) => ({ type: 'carto/addLayer', payload: {id, source, layerAttributes} });

/**
* Action to update a Layer in the store
* @param {string} id - id of the layer to update
* @param {object} layerAttributes - layer attributes to update (source, or other custom attributes)
*/
export const updateLayer = (id, layerAttributes) => ({ type: 'carto/updateLayer', payload: {id, layerAttributes} });
export const updateLayer = ({id, layerAttributes}) => ({ type: 'carto/updateLayer', payload: {id, layerAttributes} });

/**
* Action to remove a layer from the store
* @param {string} layerId - id of the layer to remove
* @param {string} id - id of the layer to remove
*/
export const removeLayer = (layerId) => ({ type: 'carto/removeLayer', payload: layerId});
export const removeLayer = (id) => ({ type: 'carto/removeLayer', payload: id});

/**
* Action to set a basemap
Expand Down