Skip to content

Commit

Permalink
docs(terra-draw): fix spelling and grammar issues in 2.STORE.md (#445)
Browse files Browse the repository at this point in the history
- parameter
- it is advisable...
- to persist the data...
- stringify

Co-authored-by: James Milner <[email protected]>
  • Loading branch information
SergeCroise and JamesLMilner authored Jan 24, 2025
1 parent fc39d44 commit 5b08dbd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions guides/2.STORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The Store is the heart of the library and is responsible for managing the state

By default Terra Draw will use [UUID4](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)) to create Feature ids. This is because these ids are broadly unique and, as such, lend themselves well to IDs where would want our features to be uniquely identifiable, potentially across drawing sessions.

It is possible to override this with an approach which aligns with your own requirements. This is done via the `idStrategy`` paramter which is passed at the top level when you create a Terra Draw instance. For example, say we wanted to be able to define our own integer incrementing id strategy, we could do that like so:
It is possible to override this with an approach which aligns with your own requirements. This is done via the `idStrategy`` parameter which is passed at the top level when you create a Terra Draw instance. For example, say we wanted to be able to define our own integer incrementing id strategy, we could do that like so:

```typescript

Expand All @@ -26,7 +26,7 @@ const draw = new TerraDraw({
});
```

You can create any strategy you like, although it advisable to start with one and stick with it consistently.
You can create any strategy you like, although it is advisable to start with one and stick with it consistently.

> [!IMPORTANT]
> You can only have one unique id per feature in each Terra Draw instance. Trying to create or add a feature with an id that already exists will throw an error!
Expand Down Expand Up @@ -173,15 +173,15 @@ See the `TerraDraw` [API Docs](https://jameslmilner.github.io/terra-draw/classes

## Restoring Data

Terra Draw is agnostic to how you want to presist the data created with it. You can store data in a remote database, in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API), [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), or any other storage mechanism you so wish. As a simple example of storing the data in `localStorage`, you could take a snapshot and restore it at a later date like so:
Terra Draw is agnostic to how you want to persist the data created with it. You can store data in a remote database, in [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API), [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), or any other storage mechanism you so wish. As a simple example of storing the data in `localStorage`, you could take a snapshot and restore it at a later date like so:

```javascript
const features = draw.getSnapshot()

// We don't want any mid points or selection points so we filter them out
const filteredFeatures = features.filter((f) => !f.properties.midPoint && !f.properties.selectionPoint)

// localStorage can only store strings, so we strinify the features first
// localStorage can only store strings, so we stringify the features first
localStorage.setItem('terra-draw-data', JSON.stringify(filteredFeatures));

// Later on, perhaps after the user has refreshed.
Expand All @@ -200,4 +200,4 @@ if (retrievedFeatures) {
5. [ ] [Styling](./5.STYLING.md)
6. [ ] [Events](./6.EVENTS.md)
7. [ ] [Development](./7.DEVELOPMENT.md)
8. [ ] [Examples](./8.EXAMPLES.md)
8. [ ] [Examples](./8.EXAMPLES.md)

0 comments on commit 5b08dbd

Please sign in to comment.