Reactive Om - Bolson-based FRP integration for yoga-om, bridging Om computations with Bolson's event system.
spago install yoga-om-core yoga-om-rom bolson- Event conversion:
omToEvent,eventToOmfor converting between Om and Events - Streaming:
streamOmsfor streaming multiple Om computations as events - Combinators:
raceEvents,filterMapOm,foldOmsfor event manipulation - Context integration:
withEventStreamfor working with events within Om context
import Yoga.Om.Rom as Rom
myEvent :: Event User
myEvent = Rom.omToEvent ctx handlers fetchUser
-- Use with Bolson's event combinators
userEvent = myEvent <#> _.nameimport Yoga.Om.Rom as Rom
processClicks :: Om _ _ Unit
processClicks = do
clickData <- Rom.eventToOm buttonClickEvent
-- Process the first click
Console.log $ "Clicked: " <> show clickDataimport Yoga.Om.Rom as Rom
allUsers :: Event User
allUsers = Rom.streamOms ctx handlers
[ fetchUser 1
, fetchUser 2
, fetchUser 3
]import Yoga.Om.Rom as Rom
runningTotal :: Event Int
runningTotal = Rom.foldOms
(\total value -> do
-- Can do Om operations here
Console.log $ "Adding " <> show value
pure (total + value)
)
0
ctx
handlers
numberEventimport Yoga.Om.Rom as Rom
reactToEvents :: Om { logger :: Logger } _ (Event String)
reactToEvents = Rom.withEventStream inputEvent \input -> do
{ logger } <- Om.ask
-- Process input within Om context
log logger input
pure (String.toUpper input)This package is designed to work seamlessly with Bolson's FRP system. You can:
- Convert Om computations to Events for use in Bolson components
- Handle user interactions (clicks, input) through Events and process them with Om
- Combine async Om operations with reactive event streams
- Maintain Om's error handling and dependency injection within event processing
Tests are colocated with the implementation in the test/ directory:
# Run tests
cd packages/yoga-om-rom && spago test
# Or from workspace root
bun test:romSee test/Test/Rom.purs for test examples.
yoga-om-rom/
├── src/
│ └── Yoga/
│ └── Om/
│ └── Rom.purs # Bolson FRP integration
└── test/ # Tests colocated here!
└── Test/
├── Main.purs # Test runner
└── Rom.purs # Rom tests
- yoga-om-core - Core Om functionality (required)
- yoga-om-node - Node.js-specific extensions
- yoga-om-strom - Pull-based streaming library (complementary)
- Bolson documentation - FRP application builder
For more examples, see the tests and main README.