{"action":"created","issue":{"url":"https://api.github.com/repos/Babylonpartners/Bento/issues/30","repository_url":"https://api.github.com/repos/Babylonpartners/Bento","labels_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/30/comments","events_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/30/events","html_url":"https://github.com/Babylonpartners/Bento/pull/30","id":325801981,"number":30,"title":"Avoid name collisions while computing `reuseIdentifier`","user":{"login":"dmcrodrigues","id":1098602,"avatar_url":"https://avatars3.githubusercontent.com/u/1098602?v=4","gravatar_id":"","url":"https://api.github.com/users/dmcrodrigues","html_url":"https://github.com/dmcrodrigues","followers_url":"https://api.github.com/users/dmcrodrigues/followers","following_url":"https://api.github.com/users/dmcrodrigues/following{/other_user}","gists_url":"https://api.github.com/users/dmcrodrigues/gists{/gist_id}","starred_url":"https://api.github.com/users/dmcrodrigues/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmcrodrigues/subscriptions","organizations_url":"https://api.github.com/users/dmcrodrigues/orgs","repos_url":"https://api.github.com/users/dmcrodrigues/repos","events_url":"https://api.github.com/users/dmcrodrigues/events{/privacy}","received_events_url":"https://api.github.com/users/dmcrodrigues/received_events","type":"User","site_admin":false},"labels":[{"id":814979154,"url":"https://api.github.com/repos/Babylonpartners/Bento/labels/bug","name":"bug","color":"d93f0b","default":true},{"id":822372302,"url":"https://api.github.com/repos/Babylonpartners/Bento/labels/ready%20for%20review","name":"ready for review","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-23T17:24:40Z","updated_at":"2018-05-23T20:52:06Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/Babylonpartners/Bento/pulls/30","html_url":"https://github.com/Babylonpartners/Bento/pull/30","diff_url":"https://github.com/Babylonpartners/Bento/pull/30.diff","patch_url":"https://github.com/Babylonpartners/Bento/pull/30.patch"},"body":"### Context\r\n\r\n`String(describing: View.self)` does not include any information about the namespace where it's defined leading to potential name collisions, which in this case means using the same identifier for views completely different.\r\n\r\nTake as an example the following snippet where we define two components, `Text` and `Image`, and both define their inner view, `View` in their own namespace. The reuse identifier will be `\"View\"` i n both components. There's also the case where name collisions can appear between components defined in different modules.\r\n\r\n```swift\r\nenum Component {}\r\n\r\nextension Component {\r\n\r\n    final class Text: Renderable {\r\n        func render(in view: View) {}\r\n    }\r\n}\r\n\r\nextension Component.Text {\r\n\r\n    public final class View: UIView {}\r\n}\r\n\r\nextension Component {\r\n\r\n    final class Image: Renderable {\r\n\r\n        func render(in view: View) {}\r\n    }\r\n}\r\n\r\nextension Component.Image {\r\n\r\n    public final class View: UIView {}\r\n}\r\n```\r\n\r\n### Solution\r\n\r\n`_typeName(_:qualified:)` is a Swift function that returns the demangled qualified name of a metatype which means will include the entire namespace where it's defined plus the module name which its part of.\r\n\r\nThis function is used by `String(reflecting:)` when the subject does not conform to neither of the following protocols:\r\n\r\n- `CustomDebugStringConvertible`\r\n- `CustomStringConvertible`\r\n- `TextOutputStreamable`\r\n\r\nConsidering the example above this will lead to the following identifiers:\r\n\r\n- `Component.Text`: `\"{Module}.Component.Text.View\"`\r\n- `Component.Image`: `\"{Module}.Component.Image.View\"`\r\n\r\nThis avoids any collisions while reusing views associated to any of this components even when the actual view shares the same name."},"comment":{"url":"https://api.github.com/repos/Babylonpartners/Bento/issues/comments/391492232","html_url":"https://github.com/Babylonpartners/Bento/pull/30#issuecomment-391492232","issue_url":"https://api.github.com/repos/Babylonpartners/Bento/issues/30","id":391492232,"user":{"login":"andersio","id":11806295,"avatar_url":"https://avatars1.githubusercontent.com/u/11806295?v=4","gravatar_id":"","url":"https://api.github.com/users/andersio","html_url":"https://github.com/andersio","followers_url":"https://api.github.com/users/andersio/followers","following_url":"https://api.github.com/users/andersio/following{/other_user}","gists_url":"https://api.github.com/users/andersio/gists{/gist_id}","starred_url":"https://api.github.com/users/andersio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andersio/subscriptions","organizations_url":"https://api.github.com/users/andersio/orgs","repos_url":"https://api.github.com/users/andersio/repos","events_url":"https://api.github.com/users/andersio/events{/privacy}","received_events_url":"https://api.github.com/users/andersio/received_events","type":"User","site_admin":false},"created_at":"2018-05-23T20:52:06Z","updated_at":"2018-05-23T20:52:06Z","author_association":"CONTRIBUTOR","body":"Shouldn't we use `String.init(reflecting:)` in this case, since this is the cannon public API?"}}
{"actor":{"display_login":"andersio"}}