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

Creating a struct to hold the RRule and allow composition #5

Open
tlvenn opened this issue Feb 2, 2018 · 6 comments
Open

Creating a struct to hold the RRule and allow composition #5

tlvenn opened this issue Feb 2, 2018 · 6 comments

Comments

@tlvenn
Copy link

tlvenn commented Feb 2, 2018

Sorry in advance for creating many issues for you... ;)

Right now the provided API is very adhoc, there is mainly 2 entry points depending if you need a stream or not and there is no struct being used to capture the RRule.

I was wondering if the api could evolve in a way where the starting point is the creation of that struct which then can be piped into functions such as:

rrule = RecurringEvents.new(~D[2016-12-07], %{freq: :daily})

RecurringEvents.all(rrule)
RecurringEvents.between(rrule, from, until)
RecurringEvents.take(rrule, 2)
RecurringEvents.to_string(rrule)

of course it would allow composition such as:

RecurringEvents.new(~D[2016-12-07], %{freq: :daily})
|> between(from, until)
|> take(2)

What do you think ?

@pbogut
Copy link
Owner

pbogut commented Feb 2, 2018

I like the idea, need to think about it.

@tlvenn
Copy link
Author

tlvenn commented Feb 3, 2018

Great, good to hear. I create another issue regarding support for rruleset which I believe also would benefit from a proper rrule struct.

@pbogut
Copy link
Owner

pbogut commented Feb 9, 2018

Do you have any idea how structure like that could look like? Or maybe you can point me to some examples?

@tlvenn
Copy link
Author

tlvenn commented Feb 10, 2018

this could be a decent start i guess:

https://github.com/jakubroztocil/rrule/blob/master/lib/rrule.js#L651

@pbogut
Copy link
Owner

pbogut commented Feb 10, 2018

Whats the benefit over simple map?

@tlvenn
Copy link
Author

tlvenn commented Feb 10, 2018

well it's structured, so you know exactly which fields can exist and you can have default values as well. You can also pattern match on the struct itself to enforce it which is pretty good when designing an API that revolve around manipulating some data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants