Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove need for PendingTasksFactory #17

Open
levibostian opened this issue Feb 7, 2018 · 2 comments
Open

Remove need for PendingTasksFactory #17

levibostian opened this issue Feb 7, 2018 · 2 comments
Labels
enhancement Needs more discussion Needs more thought before acting on it. Low priority.

Comments

@levibostian
Copy link
Owner

levibostian commented Feb 7, 2018

The purpose of the PendingTasksFactory is to construct instances of PendingTask subclasses when Wendy has decided it is time for that PendingTask to run.

Problems with PendingTasksFactory:

  • Boilerplate code to write
  • Annoying to maintain it each time you modify a PendingTask to add/remove/change dependencies.
  • Creates bugs if you forget to add to the PendingTasksFactory when you create new PendingTask subclasses
  • The reason PendingTask.tag exists is to be used with PendingTasksFactory. I describe thetag property as "in the way" as it doesn't identify the data and how it should be run by Wendy, it identifies the subclass. The tag is still required, but housing the information someway else would be a benefit to the API.

Can we remove the need to create a PendingTasksFactory?

  • No: As this issue explains, there needs to be a way to construct instances of each PendingTask along with their dependencies.

  • Yes: Maybe we could create a compile time annotation processor to generate a PendingTasksFactory for you? Android libraries, especially those like Moshi, are able to take a constructor of a class and generate code to construct instances of that class. Instead of using a PendingTask.tag property, we could create an annotation that has a property inside of that annotation for tag. This solution would cross off each item on the list above of problems with the factory.

@levibostian
Copy link
Owner Author

Funny, after creating this issue I have found a reason to keep PendingTasksFactory!

So, while I continue to use Wendy in my everyday apps, I will decide what to do with PendingTasksFactory which would include keeping it.

@levibostian
Copy link
Owner Author

Some of the inspiration and design of the Wendy lib is from evernote/android-job. If you notice from the docs, it uses a tag/factory functionality as well to map a job to a string.

With that in mind, I am not sure if there is currently a way to fix this.

@levibostian levibostian added the Needs more discussion Needs more thought before acting on it. Low priority. label Dec 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Needs more discussion Needs more thought before acting on it. Low priority.
Projects
None yet
Development

No branches or pull requests

1 participant