Skip to content

Commit

Permalink
Merge pull request #198 from johanhelsing/patch-2
Browse files Browse the repository at this point in the history
docs: Fix typos in chapter 2
  • Loading branch information
StarArawn authored Dec 18, 2022
2 parents 98acfbc + 9db3f3b commit 910a00c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions book/src/chapter_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ widget1 - entity 2
- widget2 entity 3
- widget3 entity 4
```
When widget 1 renders it's children will have random entity id's if you use bevy's default spawning commands, but by using `spawn_widget` you can guarantee somewhat consistent entities. There are a couple of a caveats to this though. If a widget is despawned due to being removed from the tree it's entity id is no longer guaranteed. This means that entities that are removed from the tree will lose access to their context and state. It's important to remember that!
When widget 1 renders, its children will have random entity id's if you use bevy's default spawning commands, but by using `spawn_widget` you can guarantee somewhat consistent entities. There are a couple of a caveats to this though. If a widget is despawned due to being removed from the tree, its entity id is no longer guaranteed. This means that entities that are removed from the tree will lose access to their context and state. It's important to remember that!

### Relationships

Widgets, by the nature of them being stored as a tree, contain certain relationships. The most common one is the *
parent-child* relationship. A widget may contain zero or more children.
Widgets, by the nature of them being stored as a tree, contain certain relationships. The most common one is the *parent-child* relationship. A widget may contain zero or more children.

<p align="center">
<img alt="Diagram showing the parent-child relationship" src="img/parent-child.svg" />
Expand Down Expand Up @@ -106,4 +105,4 @@ The last core concept is that of *widget lifecycle*. Widgets have a lifecycle as
2. Update or Diff - During each update loop the widgets are diffed with previous values from the last update to see if they have changed. If a widget has changed it is re-rendered.
3. Render - Render occurs when a widget has changed and allows users to change behavior according to entity changes.
4. Layout - Occurs after the entire tree has been updated. Widget entities marked as "dirty" will have their rendering and layout recalculated.
5. Removal/Despawning - Entities that are removed from the tree are despawned additionally any children they had are also despawned and removed from the tree. It's important to avoid removing a widget from the tree if you need to preserve that widgets state.
5. Removal/Despawning - Entities that are removed from the tree are despawned additionally any children they had are also despawned and removed from the tree. It's important to avoid removing a widget from the tree if you need to preserve that widgets state.

0 comments on commit 910a00c

Please sign in to comment.