Skip to content

Commit 0a6b618

Browse files
committed
merged
1 parent d7ceeba commit 0a6b618

File tree

4 files changed

+19
-371
lines changed

4 files changed

+19
-371
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* [Operations](operations/README.md)
3333
* [Policies](policies/README.md)
3434
* [Internationalization](internationalization/README.md)
35-
* [Development Workflow and Procedures](development-workflow/README.md)
35+
* [Development Tools, Workflow and Procedures](development-workflow/README.md)
3636
* [Debugging](development-workflow/debugging.md)
3737
* [HyperTrace](development-workflow/hyper-trace.md)
3838
* [HyperSpec](development-workflow/hyper-spec/README.md)

docs/hyper-model/README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In other words, one browser creates, updates, or destroys a Model, and the chang
1515

1616
* You access your Model data in your Components, Operations, and Stores just like you would on the server or in an ERB or HAML view file.
1717
* If an optional push transport is connected Hyperstack broadcasts any changes made to your ActiveRecord models as they are persisted on the server or updated by one of the authorized clients.
18-
* Some Models can be designated as _server-only_ which means they are not available to the Isomorphic code.
18+
* Some Models (or even parts of Models) can be designated as _server-only_ which means they are not available to the client code.
1919

2020
For example, consider a simple model called `Dictionary` which might be part of Wiktionary type app.
2121

@@ -38,8 +38,7 @@ class WordOfTheDay < Hyperstack::Component
3838

3939
def pick_entry!
4040
# pick a random word and assign the selected record to entry
41-
@entry = Dictionary.defined.all[rand(Dictionary.defined.count)]
42-
force_update! # redraw our component when the word changes
41+
mutate @entry = Dictionary.defined[rand(Dictionary.defined.count)]
4342
# Notice that we use standard ActiveRecord constructs to select our
4443
# random entry value
4544
end
@@ -61,7 +60,8 @@ class WordOfTheDay < Hyperstack::Component
6160
end
6261
```
6362

64-
For complete examples with _push_ updates, see any of the apps in the `examples` directory, or build your own in 5 minutes following one of the quickstart guides:
63+
**This is the entire code. There are no application APIs needed. The synchronization between server and client is completely taken care of by HyperModel. If you have
64+
an existing code base little to updates to your existing Models is needed, and you will use the same ActiveRecord API you have been using.**
6565

6666
## Isomorphic Models
6767

@@ -284,7 +284,7 @@ To force the value to be recomputed at the server append a `!` to the end of the
284284

285285
`columns_hash`: returns the details of the columns specification. Note that on the server `columns_hash` returns a hash of objects specifying column information. On the client the entire structure is just one big hash of hashes.
286286

287-
`abstract_class=`, `abstract_class?`, `primary_key`, `primary_key=`, `inheritance_column`, `inheritance_column=`, `model_name`: All work as on the server. See ActiveRecord documentation for more info.
287+
`abstract_class=`, `abstract_class?`, `primary_key`, `primary_key=`, `inheritance_column`, `inheritance_column=`, `model_name`, `serialize`, `alias_attribute`, `table_name`: All work as on the server. See ActiveRecord documentation for more info.
288288

289289
### Instance Methods
290290

@@ -313,6 +313,10 @@ end
313313

314314
After a save operation completes the models will have an `errors` hash \(just like on the server\) with any validation problems.
315315

316+
`save` does not fail, but rather returns `{success: false ...}`. If there was an
317+
exception the `message` key will hold the error information, otherwise the errors will
318+
be stored in the records error data (as on the server.)
319+
316320
During the save operation the method `saving?` will return `true`. This can be used to instead of \(or with\) the promise to update the screen:
317321

318322
```ruby
@@ -333,7 +337,9 @@ end
333337

334338
Like `save` destroy returns a promise that is resolved when the destroy completes.
335339

336-
After the destroy completes the record's `destroyed?` method will return true.
340+
After the destroy completes successfully the record's `destroyed?` method will return true.
341+
342+
Like `save` destroy never fails, but rather returns `{success: false...}`
337343

338344
#### Other Instance Methods
339345

@@ -391,12 +397,12 @@ The `load` method takes a list of attributes \(symbols\) and will insure these a
391397
before_mount do
392398
Todo.find(1).load(:name).then do |name|
393399
@name = name;
394-
state.loaded! true
400+
mutate @loaded = true
395401
end
396402
end
397403
```
398404

399-
Think hard about how you are using this, as Hyperstack already acts as flux store, and is managing state for you. It may be you are just creating a redundant store!
405+
> Think hard about how you are using this, as Hyperstack already acts as flux store, and is managing state for you. It may be you are just creating a redundant store!
400406
401407
## Client Side Scoping
402408

docs/hyper-state/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ The `Hyperstack::State::Observable` module allows you to build classes that shar
99

1010
The easiest way to understand HyperState is by example. If you you did not see the Tic-Tac-Toe example, then **[please review it now](client-dsl/interlude-tic-tac-toe.md)**, as we are going to use this to demonstrate how to use the `Hyperstack::State::Observable` module.
1111

12-
In our original Tic Tac Toe implementation the state of the game was stored in the `DisplayGame` component. State was updated by
13-
"bubbling up" events from lower level components up to `DisplayGame` where the event handers updated the state.
12+
In our original Tic-Tac-Toe implementation the state of the game was stored in the `DisplayGame` component. State was updated by
13+
"bubbling up" events from lower level components up to `DisplayGame` where the event handler updated the state.
1414

1515
This is a nice simple approach but suffers from two issues:
1616
+ Each level of lower level components must be responsible for bubbling up the events to the higher component.
@@ -366,7 +366,7 @@ the appropriate `mutate` or `observe` method.
366366
Typically in a large system you will have one or more central stores, and what you end up passing as parameters are either instances of those stores, or some other kind of index into the store. Or if (as in the case of our Game) there is only one store, you
367367
need not pass any parameters at all.
368368

369-
We can rewrite the last iteration of DisplayBoard to demonstrate this:
369+
We can rewrite the previous iteration of `DisplayBoard` to demonstrate this:
370370

371371
```ruby
372372
class DisplaySquare
@@ -391,7 +391,7 @@ Here `DisplayBoard` no longer takes any parameter (and should be renamed again t
391391
`DisplaySquare` takes the id of the square to display, but the game or the current board are never passed as parameters;
392392
there is no need to as they are implicit.
393393

394-
Whether to not pass store objects, an instance of a store, and index into the store is a design decision that depends on
394+
Whether to pass (or not pass) a store class, an instance of a store, or some other index into the store is a design decision that depends on
395395
lots of factors, mainly how you see your application evolving over time.
396396

397397
### Summary of Methods

0 commit comments

Comments
 (0)