Open sccolbert opened 4 years ago
So this parallels the ideas behind tokens, but now uses Symbols for their global nature (and since they are available now)?
We had also discussed using Symbols for tokens themselves so you could have multiple providers.
We had also discussed using Symbols for tokens themselves so you could have multiple providers.
That's right. Versioned interfaces.
So this parallels the ideas behind tokens, but now uses Symbols for their global nature (and since they are available now)?
Somewhat. I think it's more subtle than first glance. TypeScript may still not like it, for example.
We had also discussed using Symbols for tokens themselves so you could have multiple providers.
Yep.
Forcing Phosphor to be a singleton on the page is "not nice" for projects which consume Phosphor. It means new functionality in Phosphor is not available for the users of those downstream projects until those projects update their dependencies. For Phosphor 2.0 (which should hopefully be the last major version of Phosphor) I think we can do better.
One idea that I have is to leverage
Symbol.for('@phosphor/widgets@2.x')
and tag theWidget
prototype with that Symbol for each minor release. Since the Symbol is guaranteed to be global on the page, it would let duplicate prototypes function just fine, because we could guarantee they have the needed API. Instead of using theinstanceof
operator, we could have some convenience functions for checking the presence of the symbols.This idea may have holes, but it's a good starting point I think.
CC @afshin @blink1073 @jasongrout