Future Actions
History Key
- New content
Removed content
Recent Versions
Choose two versions to compare, or click the link to view it.
Snooze lets you express the fact that a resource is able to send data to other resources. For example, a book page with a form to add a comment will post to /book/{bookid}/comments. When getting the book page, the controller action adds a "FutureAction" into the view model.
A FutureAction contains the HTTP method, URL and optionally some existing entity. The entity could be some existing data you are editing.
You can create a future action using an action expression:
var addComment = new FutureAction(() => Post(commentsUrl, new NewComment()))
Pass this FutureAction to the view. Generating an HTML form is easy and you could even write a helper to automate the task.
The above example referenced an action in the same controller. However, you can specify any controller by using the generic FutureAction<T> instead:
var addComment = new FutureAction<CommentsController>(c => c.Post(commentsUrl, new NewComment()))