preaction / Yancy

The Best Web Framework Deserves the Best Content Management System
http://preaction.me/yancy/
Other
54 stars 21 forks source link

Backend events #52

Closed preaction closed 3 years ago

preaction commented 5 years ago

Every backend should emit events in the following circumstances:

Backends should inherit from Mojo::EventEmitter. Events can be added to the backend by using the standard Mojo::EventEmitter methods. These events should be documented in Yancy::Backend.

The documentation should explain that the events will only be handled by the worker that handles the request. So these events cannot be used, by themselves, to broadcast updates to other clients unless all the clients are connected to the same worker, or some kind of messaging system is used (like Mercury).

preaction commented 5 years ago

Instead of requiring all backends to support this which may only be used in limited circumstances, we should make this a role that users can apply to their backend object before configuring the Yancy plugin. This opens up new avenues of functionality, so I should also blog about it.

preaction commented 3 years ago

This feature is a good idea, but would be better implemented in Yancy::Model, which can be connected to any backend. But also, using Yancy::Model is itself a way to get these hooks to do whatever you want.