Преглед на файлове

Add intro line to README; Update coroutine example;

bjorn преди 10 години
родител
ревизия
4175fde3a7
променени са 2 файла, в които са добавени 12 реда и са изтрити 6 реда
  1. 6 3
      README.md
  2. 6 3
      examples/coroutine.lua

+ 6 - 3
README.md

@@ -1,13 +1,16 @@
 RxLua
 RxLua
 ===
 ===
 
 
-How to use:
+[Reactive Extensions](http://reactivex.io) for Lua.
+
+Examples
+---
+
+Cheer someone on using functional reactive programming:
 
 
 ```lua
 ```lua
 local Rx = require 'rx'
 local Rx = require 'rx'
 
 
--- Cheer someone on using functional reactive programming
-
 local observable = Rx.Observable.fromCoroutine(function()
 local observable = Rx.Observable.fromCoroutine(function()
   for i = 2, 8, 2 do
   for i = 2, 8, 2 do
     coroutine.yield(i)
     coroutine.yield(i)

+ 6 - 3
examples/coroutine.lua

@@ -1,7 +1,8 @@
 local Rx = require 'rx'
 local Rx = require 'rx'
 
 
--- Observable created from a coroutine.
-local cheer = coroutine.create(function()
+-- Cheer someone on using functional reactive programming
+
+local observable = Rx.Observable.fromCoroutine(function()
   for i = 2, 8, 2 do
   for i = 2, 8, 2 do
     coroutine.yield(i)
     coroutine.yield(i)
   end
   end
@@ -9,7 +10,9 @@ local cheer = coroutine.create(function()
   return 'who do we appreciate'
   return 'who do we appreciate'
 end)
 end)
 
 
-Rx.Observable.fromCoroutine(cheer):dump('cheer')
+observable
+  :map(function(value) return value .. '!' end)
+  :subscribe(print)
 
 
 repeat
 repeat
   Rx.scheduler:update()
   Rx.scheduler:update()