You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Barrie Hadfield edited this page Jan 6, 2017
·
3 revisions
@barriehadfield
# Use case: we have a list of books and want to add one to the users basketmoduleComponentsmoduleBooksclassList < React::Component::Baserender(DIV)doBook.all.eachdo |book|
li{"Add #{book.name}"}.on(:click)doAddBookToBasket(book: book)do |outcome|
alert"Failed to add the book"unlessoutcome.success?endendendendendendendmoduleOperationsmoduleBooksclassAddBookToBasket < HyperLoop::Operationparam:book,type: Bookdefexecuteacting_user.basket << bookEmailUserAboutBook(book: params.book,user: acting_user)endendendclassEmailUserAboutBook < HyperLoop::ServerOperation# client code knows nothing about UserMailer, so this has to be a Server Operationallow_operation{acting_user}param:book,type: Bookparam:user,type: UserexecutedoUserMailer.book_email(params.user,params.book)endendendend