question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`oncreate` vs `onupdate`

See original GitHub issue

I noticed that onupdate doesn’t fire during the first update, is this intentional?

I think, in most systems that offer both a create and update notification, the initial creation triggers both a create and an update notification, because there isn’t typically much use for an update notification that doesn’t fire the first time.

Typically the notifications you need are for creation, for destruction, or for all updates - rarely does anyone need a notification for “all updates except the first one”.

Thoughts?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:45 (41 by maintainers)

github_iconTop GitHub Comments

2reactions
mindplay-dkcommented, Jan 9, 2018

By no means “there” yet, and I have to quit for today, but I did make some interesting progress.

https://jsfiddle.net/mindplay/o2rdL259/4/

I’ve extended the h function so I can test if type is a constructor that extends Component - right now it’s recreating the component on every iteration, but so far so good. Next step is to try to inject the component instance into a reserved field in props, and make it carry over via oldProps, which should be possible by proxying oncreate and onupdate.

The sample class here illustrates what I’m trying to do - I think that class-based components do make sense here - you’d be able to encapsulate the model and the render function into a self-sufficient, reusable component. It’s not exactly the React approach, as I’m putting the component itself in charge of managing it’s own state and calling Component.invalidate() to re-render. We’ll see if this pans out… 😃

2reactions
jorgebucarancommented, Jan 8, 2018

Or we could leave things the way they are.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make Function trigger only onCreate and onUpdate?
onCreate Triggered when a document is written to for the first time. onUpdate Triggered when a document already exists and has any value....
Read more >
Cloud Firestore triggers | Cloud Functions for Firebase
Triggered when onCreate , onUpdate or onDelete is triggered. Note: Cloud Firestore events will trigger only on document changes. An update to a...
Read more >
onUpdate (and onCreate) function triggered when document ...
Result: logs show both onCreate and onUpdate are called. The outcome of the equivalent Node app seems to be correct. Only onCreate called...
Read more >
Entity behaviors - Events - Cycle ORM
OnCreate ; OnUpdate; OnDelete; QueueCommand. The package dispatch several events, allowing you to hook into the following moments in an entity's lifecycle:.
Read more >
Lifecycle methods - Mithril.js
Usage · The DOM element lifecycle · oninit · oncreate · onupdate · onbeforeremove · onremove · onbeforeupdate.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found