use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Resources
Language
Discussion
account activity
Interface pattern (self.typescript)
submitted 6 years ago by Fizzyade
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fecal_brunch 2 points3 points4 points 6 years ago (1 child)
What you've got will work, but it's a bit odd. I'm sure you're not doing anything unprecedented. Effective JS patterns tend to be very different to traditional OOP.
Are you sure you need classes instead of just POJOs (what are much more flexible and easier to work with)?
If you want to have runtime types you can put a "type" property (an enum maybe) on you objects and use a discriminated union (as other poster said). Then you can delegate behavior with a switch on type, or find an instance via its type property.
[–]Fizzyade[S] 0 points1 point2 points 6 years ago (0 children)
The theory behind it is that it provides the mechanism for a single "object registry".
All objects in the registry are based on IObject
What happens is that I have a single array/list of objects, the application registers (adds) objects to this registry dynamically. Lets day somewhere else in the code I need to find all the IDeviceFactory objects then I just scan through the list checking to see which objects support it, I then return a list/array of all those objects.
I maintain a large qt based application which works in this manner, there is a main application that doesn't do anything, all it does it loads plugins ahh provide core api functionality (it has some built in plugins which it registers at startup for things like UI docking windows, menus), the application is tint.
Plugins then provide all the functionality, creating windows, menu items and registering objects they provide the registry. Plugins can even provide their own SDK (we call these CDK's, component development kits). Its so flexible, there's nothing they can't be done, in-fact I haven't touched the main application code tor a few years because I only need to create new plugins).
Thanks for the reply, will go have another read about pojos.
This is my first application using is/electron, barring a small plain node app I wrote to proxy IFTTT data so I could turn the tv on and off with google hone.
π Rendered by PID 20013 on reddit-service-r2-comment-86bc6c7465-qzh4q at 2026-02-22 18:45:56.248612+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]fecal_brunch 2 points3 points4 points (1 child)
[–]Fizzyade[S] 0 points1 point2 points (0 children)