Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Lights appearing in Client#lights collection before fully loaded #3

Closed
johncarney opened this issue Mar 18, 2014 · 5 comments
Closed

Comments

@johncarney
Copy link

It appears that sometimes a light can appear in the Client#lights collection before its properties are fully loaded.

Ideally, only lights that are fully "loaded" should appear in Client#lights. Perhaps lights that are known, but not loaded could be managed in a separate private collection.

@johncarney
Copy link
Author

Or perhaps the current Client#lights could be renamed to known_lights and lights rewritten like so:

def lights
  known_lights.select(&:label)
end

@chendo
Copy link
Contributor

chendo commented Mar 18, 2014

If you call Light#color, #label or #power and it doesn't have it cached, it will block and fetch it. Light#inspect/to_s does not fetch for performance reasons.

@chendo
Copy link
Contributor

chendo commented Mar 18, 2014

If you ran lights.select { |light| light.label =~ /foo/ }, it will fetch all the labels if they haven't been fetched already

@johncarney
Copy link
Author

Ah ok. Forget I spoke then :)

@chendo
Copy link
Contributor

chendo commented Mar 18, 2014

:)

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

No branches or pull requests

2 participants