Giter Club home page Giter Club logo

Comments (12)

benfurfie avatar benfurfie commented on June 19, 2024

+1 for this.

from ideas.

edalzell avatar edalzell commented on June 19, 2024

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.

edalzell avatar edalzell commented on June 19, 2024

Perhaps related: statamic/v2-hub#2520

from ideas.

jesseleite avatar jesseleite commented on June 19, 2024

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.

edalzell avatar edalzell commented on June 19, 2024

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.

jesseleite avatar jesseleite commented on June 19, 2024

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.

edalzell avatar edalzell commented on June 19, 2024

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.

jesseleite avatar jesseleite commented on June 19, 2024

Not saying that is the solution, just adding context to the discussion around events.

from ideas.

jasonvarga avatar jasonvarga commented on June 19, 2024

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.

edalzell avatar edalzell commented on June 19, 2024

I only want to things if the content has been saved though...validation passed, all Statamic stuff done etc.

from ideas.

aerni avatar aerni commented on June 19, 2024

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.

FrittenKeeZ avatar FrittenKeeZ commented on June 19, 2024

A similar exists boolean prop to determine whether an entity was deleted would be nice.

from ideas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.