Skip to content

Commit

Permalink
README: add some examples
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Feb 4, 2014
1 parent 5e0a28d commit 974e054
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Expand Up @@ -89,6 +89,38 @@ EventSource
-----------
Event sources have been implemented and are easily configurable with blocks.

```ruby
Browser::EventSource.new '/events' do |es|
es.on :message do |e|
alert e.data
end

es.on :custom do |e|
alert "custom #{e.data}"
end
end

Database SQL
------------
WebSQL has been fully wrapped.

```ruby
db = Browser::Database::SQL.new 'test'
db.transaction {|t|
t.query('CREATE TABLE test(ID INTEGER PRIMARY KEY ASC, text TEXT)').then {
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 1, 'huehue')
}.then {
t.query('INSERT INTO test (id, text) VALUES(?, ?)', 2, 'jajaja')
}.then {
t.query('SELECT * FROM test')
}.then {|r|
r.each {|row|
alert row.inspect
}
}
}
```

History
-------
The HTML5 History API has been fully wrapped.
Expand Down

0 comments on commit 974e054

Please sign in to comment.