Comments (11)
The way I would name the above method is:
func spotable(_ spot: Spotable, itemSelected item: Item, view: SpotView)
Reasoning: The first argument should always match the object that you're the delegate for. This is both in line with Apple's naming convention, but also improves API discoverability and makes for an easier grouping of methods (and better auto complete). _
is used because it's clear from the method name that the first argument is going to be a Spotable
. The verb is not formulated as didSelect
because in this case the Spot itself didn't select the item - the user did. This would be different if it was (for example) an image loader that itself downloaded an image (func imageLoader(_ imageLoader: ImageLoader, didLoadImage image: UIImage)
).
from spots.
Oh, I don't think I'm torn anymore 😁
I like this suggestion, it would of course have implications for the other delegate proposals that I've made but I think this would be a good way to go.
from spots.
@zenangst yeah we could do that. For now I think we can use ui
method to retrieve the View
?
from spots.
This is correct :)
from spots.
Would be a nice addition 👍
from spots.
I propose that the version 6.0.0
version would look something like this;
func spotsDidSelect(view: SpotView, item: Item, in spot: Spotable) {
from spots.
@JohnSundell mentioned a variation of this that can also be very interesting (sorry mate, forgot about that).
It would end up looking something like this:
func spot(view: SpotView, _ spot: Spotable, itemSelected item: Item)
I just thought about another variant.
func spotsDid(selectView view: SpotView, itemSelected item: Item, in spot: Spotable)
from spots.
from spots.
What do you guys think @hyperoslo/ios ?
from spots.
I like @JohnSundell's suggestion, the only thing I' not sure about is spotable
in the name.
from spots.
I think it makes sense in the context, however... I don't know if I would make that connection straight away as the intention on what happened is located later in the signature. But it would be easily scoped into spot..
which would make it super easy to discover the methods. Also like @JohnSundell described, if you imply it in the method name, you can drop the first label.
from spots.
Related Issues (20)
- Add a test for checking the new `clean` property in `prepareItems`. HOT 1
- Method does not override any method from its superclass
- Improve naming of `itemsPerRow` HOT 12
- Update Example apps HOT 8
- CryptoSwift requirement 0.6.0 does not work with Xcode 9. HOT 4
- Building Scheme Spots-tvOS exit error 65 HOT 6
- no ad was available Apple TV os HOT 4
- Cant Play add HOT 1
- Item with uilabel not expanding with text after sizeToFit HOT 14
- Event handling HOT 3
- Enable linting HOT 1
- func configure(_ item: inout Item) change. HOT 5
- please add more visual example projects just like the cover image implied HOT 1
- Feature Request: Migration from HUB to Spots?
- ComponentDelegate is nil HOT 3
- compile error with Xcode 9.3
- weird problem on pop. HOT 1
- Documentation
- Child components
- Crash on iOS 13 Beta 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spots.