Comments (12)
+1 for this.
from ideas.
As per discussion w/ Jesse in Discord, it would be even better if the event was only fired when there's changed/new data.
from ideas.
Perhaps related: statamic/v2-hub#2520
from ideas.
It might be better, just a thought.
Anyway, would like to see more practical examples of where you might actually use old data and/or dirty booleans in our data events? Providing old data to all of the events across our system could get messy.
from ideas.
Like I said above Jesse, it's to prevent a loop.
I'll try to find some code that I've used in the past.
from ideas.
Theoretically, you'd be able to prevent loops by hooking into EntrySaving
and cancelling a save. These aren't all implemented yet, but the plan is that every data type will fire these events...
EntrySaving
(pre-save, with the ability to cancel save)EntrySaved
(post-save)EntryDeleting
(pre-delete, with the ability to cancel delete)EntryDeleted
(post-delete)
(The Saved
and Deleted
events are coming soon with the new git integration feature. The Saving
and Deleting
events aren't in there yet, but coming at some point.)
from ideas.
How would I know to cancel the save if I don't know if anything has changed? So either we have to know if something has changed, or the event can't fire when nothing has changed.
from ideas.
Not saying that is the solution, just adding context to the discussion around events.
from ideas.
It's a lot simpler for Eloquent Models to check if they're dirty since they only have attributes
and original
arrays to worry about.
Perhaps the "saving" events are a better place for when you want to modify a thing. Then you don't have to re-save them.
from ideas.
I only want to things if the content has been saved though...validation passed, all Statamic stuff done etc.
from ideas.
This would be a very much appreciated addition! I've come across this a lot where I needed to check if a value has been changed or not. And only perform some logic when it did change. Right now I'm working around this with either some boolean values in the entry data or with some cache. But both feel very dirty and unreliable.
from ideas.
A similar exists
boolean prop to determine whether an entity was deleted would be nice.
from ideas.
Related Issues (20)
- Sorting groups using group_by HOT 1
- Can we replace the ArrayCollection with Enumerable for ProvidesSearchables interface. HOT 1
- Column selection in stack picker
- Ability to use the link field with taxonomy terms
- Customization of taxonomy permalink structure HOT 2
- Save fieldsets in local addon, not in overridden fieldset path
- Ability to "select" the relationship fields that get augmented HOT 3
- Localizable fields in Assets HOT 1
- Call to a member function collections() on null HOT 6
- 🔑 Passkeys!
- Moving an item in tree view does not invalidate its cache
- Warm static page cache on page save HOT 7
- Create views in collections for everyone HOT 2
- Color fieldtype improvements
- Link fieldtype: Pass the selected type in the field data
- Retrieve the localized value of any field for any site
- Allow bard field toolbar stickiness HOT 2
- Allow overwriting the column used by `unique_user_value` validator
- Make the validation error message 'The data was invalid' clearer in Assets manager
- Improve accessibility in prerendered form fields HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ideas.