-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
add chainable method for returning flash object #214
Conversation
6cb5be7
to
ff85f7f
Compare
@@ -68,6 +68,13 @@ export default Service.extend({ | |||
return this; | |||
}, | |||
|
|||
getFlashObject() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO getLastFlashObject
holds more meaning than getFlashObject
.
Or since we are talking about a queue of message, why not provide accessors such as peekFirst
and peekLast
?
They would return undefined
for an empty queue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@panthony trying to wrap this up today. I like peekLast
and peekFirst
but what about a specific index? Or should we not worry about that?
I kind of like getFlashObject
because it implies that it is chainable and returns the flash object we just added. If someone wants to get a specific index, they can access the queue from the service directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sbatson5 well I first I though of peekAt(idx)
that would be called by peekFirst
and peekLast
but it was maybe too much as the requirement was only to retrieve the last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my current implem:
And as I reviewed again I just noticed that I have an unnecessary call to get(this, 'queue')
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
I'm thinking of maybe having all 3 methods. I like the readability of:
flash.add({ message: 'foo' }).getFlashObject();
as it returns the object we just added. peekLast
doesn't make sense to chain.
Then we can still have peekLast
and peekFirst
but encourage that they aren't chainable but are public calls to our service.
Thoughts?
☔ The latest upstream changes (presumably 29351d4) made this pull request unmergeable. Please resolve the merge conflicts. |
ff85f7f
to
9693974
Compare
@sbatson5 wow I was not aware of the I'd say that maybe getFlashObject is redundant but it's a matter of taste I guess. Not sure why And didn't you say that Or maybe rename |
@panthony I'm just thinking of the naming convention:
|
a395f2c
to
0369c6a
Compare
@sbatson5 Ok ! So this is looking great in that case :) |
add peek methods to return first and last objects
0369c6a
to
10032d5
Compare
What's in this PR
This should address the issue raised by #154. A fluent API allows for chaining methods, but does not give access to the flash object. For users who want to manipulate the object directly, they can access it with the
getFlashObject
method, which will return the last object added to the queue.getFlashObject