romgrk / node-todoist

nodejs implementation of todoist sync API
21 stars 12 forks source link

Way to incrementally sync without keeping process running #14

Closed rcodesmith closed 3 years ago

rcodesmith commented 3 years ago

I want to use the incremental sync feature of the todoist API. It looks like this library support you calling sync() multiple times on the same Todoist object, each time getting only the data that changed.

I'd like to use incremental sync in a serverless function (e.g. lambda function) where no state (no Todoist object) is being saved between calls to sync(). Is this supported?

romgrk commented 3 years ago

In a stateless environment, it would fetch all the data each time, just as when you call .sync() initially. This is supported. Consider using .sync(resourceType: string[]) with resourceType being the data you're interested in to reduce your bandwidth usage, refer to todoist's documentation for more details.

Closing to keep issues low & clean, but please ask if you have more questions.

rcodesmith commented 3 years ago

Thanks for the info. Is there a way for me to save the sync_token, and pass it into the library so I only get newly updated entities? I can't really save an instance of the api per todoist account to sync with, but I can definetely save the sync_token per todoist account I want to sync with.

romgrk commented 3 years ago

I have added accessors for you to get and set the syncToken. They have been published in 0.5.0 at the moment. I'm not going to document them at the moment because I haven't tested anything and am not sure of the implications of setting the syncToken directly, but as far as I understand the API this should allow for your use case. Let me know if there is anything more that can be done, and don't hesitate to open a PR if you want to improve things.

rcodesmith commented 3 years ago

Great! I'll try it out and report back.