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

Fix the access to the renderer from every node #65

Merged
merged 1 commit into from Nov 16, 2016
Merged

Conversation

smaramba
Copy link
Contributor

This pull request fix the access to the renderer from every node.
In the previous implementation the renderer computed property of the AnyNode protocol was erased by the renderer variable of the Node class.

Solution: store the reference of the renderer inside a private _renderer: Renderer? variable in Node, expose a computed property renderer: Renderer from AnyNode.

public class Renderer {
}

public class Node<T> {
  private var _renderer: Renderer?
  public var parent: AnyNode?
  
  public var renderer: Renderer {
    guard self._renderer == nil else { return self._renderer! }
    return self.parent!.renderer
  }
}

public protocol AnyNode: class {
  var renderer: Renderer { get }
  var parent: AnyNode? { get }
}

protocol InternalAnyNode: AnyNode {}

extension Node: InternalAnyNode {}

@bolismauro bolismauro merged commit fedb08c into master Nov 16, 2016
@bolismauro bolismauro deleted the fix/renderer branch November 16, 2016 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants