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

docs(terra-draw): fix spelling and grammar issues in 2.STORE.md #445

Merged
merged 2 commits into from
Jan 24, 2025
Merged
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
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)
Loading