« first day (1941 days earlier)      last day (3005 days later) » 

6:00 PM
@ndugger It's not always you passing the args. With a plugin architecture, you'll register the various modules, then ask a factory for an instance of class X and it will check the ctor, fill in params, and instantiate.
 
I'd argue that the factory is a separate concept from the DI
 
@jAndy and you wonder why we ping you with the game all the time, actually you don't wonder about us reminding you of the game or may be you do wonder about us reminding you off the game. I guess we will never know if we do or we do not remind you of the game or is it you who reminds us of the game. This long message was just to remind you several times about the game, the game, yes that one the game that you have just lost.
 
It's especially useful in a strongly-typed language, where your constructor can require a parameter with interface Y, you register any class subY with the factory as the instance of Y, and the factory hands it out.
 
injection does not cover creation of the objects, or it shouldn't, rather
 
@ndugger The factory performs DI: it injects the dependencies during instantiation.
You should only really manually inject for tests.
Even then, you're almost better off registering your test mock with the DI factory.
 
6:02 PM
@ndugger Even just the constructor argument version of Dependency Injection is a design choice to whether or not you use it
 
IMO, constructor DI is better than field because you can test without reflection.
 
neeeaaat. the JC2 multiplayer was rough but showed potential.
 
It got smoother over time
They fixed a lot of the sync issues
 
did they ever get a system to spawn on people instead of having to find them in the world?
it was kind of hilarious but also frustrating to try to find friends by describing what landmarks you were close to.
 
6:10 PM
I don't recall
 
so how would i convert a websocket message that has bytes encoded in ISO-8859-1 to utf-8 so i am not getting garbage as my message i recieved?
 
I'm making an API endpoint that takes query params to filter/sort an array of products and return the result. I'm finding lots of resources for how a REST API should act but is there an agreed upon standard for what the returned data should look like?
 
@Retsam I like this sort of DI: gist.github.com/ssube/20e1e156439a25c45ade
 
!!s/:.+$/CK/
 
@ndugger @SterlingArcher in your .gitconfig file add thisCK (source)
 
6:13 PM
pls
 
once I got the hang of it, I started using it absolutely everywhere, because it's super simple and powaful
 
@ndugger @Retsam I like this sort of DICK (source)
 
@ssube Decorators; fancy. (That's ES7 stuff, right?)
 
Jordan loves ES7 now
async/await
do it
 
6:14 PM
you can do it just as well with a field
 
decorator on a class is nothing more than decorator(class)
 
class FilesystemUser { static get dependencies() { return [IFilesystem]; } }
 
@SterlingArcher Proud of you, bruh
 
Madara wrote and taught me lol
 
6:15 PM
and const args = ctor.interfaces.map(iface => this._deps.get(iface)); becomes const args = ctor.dependencies.map(...)
if you need to avoid es7 for some reason. The decorator is cleaner, IMO
 
@SterlingArcher just so you know, you can do...

app.route("/games")
    .get(async (req, res) => {
        // await inside of the callback
    });
 
Yeah; I'm just skiddish about using non-standard JS features.
 
guice also uses "modules" of deps and immutable injectors, so you register multiple small modules (maps) and it builds a tree of injectors
which allows you to have multiple parts of your app sharing deps and other parts not
 
@ndugger yeah but I don't think my entire route should be async
 
@SterlingArcher Sure, that's up to you. Just making sure you know all you can do
 
6:19 PM
@ssube Thanks for the link; that does look like an interesting pattern.
 
@Retsam there were a couple bugs, so check it again
 
@SterlingArcher it's "async" anyway
 
made it a little more idiomatic and set it up to take multiple deps
and because it's all constructor-based, testing is as simple as new FilesystemUser(mockFilesystem, mockUser)
 
Does ES6 have some shorthand for this, or am I thinking of Coffeescript:
constructor(foo) {
    this.foo = foo;
}
@ssube Yeah, testing is the primary reason I'm thinking of DI, more so than switching out implementations of various objects.
 
What do you mean a shorthand? That's pretty short.
 
6:24 PM
Testing (with mocks) is switching out implementations. ;)
That's how you test a single unit: mock the inputs and dependencies, check the output.
 
@ndugger Coffeescript lets you do constructor(@foo) { }. (@ means "this" in coffeescript)
 
ew
implicitly setting properties like that is ugly. I'd much rather do things explicitly, 9 times out of 10
 
@Retsam You don't even need the curly braces..
 
@ndugger Eh; it just eliminates boilerplate, IMO.
 
@ndugger The @ indicates to Coffeescript to bind foo to this.
 
6:30 PM
listing all of your params twice is a pain
 
it also eliminates visibility, though I won't say it's that much of an issue here
 
And some people don't feel comfortable with this.foo = foo, so they'll do this.foo = _foo which is uglier, too.
 
I just don't personally like it, but the answer is no; ES does not have a shorthand for this (yet)
 
new receipt: pizza soup
 
Awww yeeaahhhh
 
6:32 PM
@KarelG recipe*
 
@Retsam _foo is convention for private
 
Next step, the backend
 
it's so you can do get foo() { return this._foo; } and no set foo
 
Now, room question
If you were in a lobby, would you want an auto-refreshing lobby count?
Or a user refresh button
 
in a lobby, like viewing games/servers or watching a particular game/server?
 
6:33 PM
@Trasiva just googled "receipt" and it's a ticket with prices ... ok wrong name. thx for correcting
 
@ssube Yeah; it's used for private, but I've also seen _foo used as a constructor argument just to avoid this.foo = foo
 
I was thinking auto, but the numbers and games that fill up and drop off would make the page a bit of a hassle to track a specific game (without it's specific ID)
 
I wouldn't expect the server list to update, but I would expect the pending game to update when people joined
 
@KarelG No worries, I know you're not an english native. Just tossing a helping hand. ;)
 
@ssube like looking at a list of games and their player counts (X/15)
If a game becomes 15/15, it drops from the list bc full and started
So the list would update often (assuming many games and players)
 
6:35 PM
update every minute or so
 
@ton.yeung it's a lobby
 
I think that's what Steam does for multiplayer
 
You can either join a game, or create your own
I think that's a good idea. I'll give a warning "List refreshes every minute, or click "here" to refresh it now"
Exactly
Aww fuck, I forgot about leaving lol I'll have to add that
 
@ton.yeung I would think it was made by EA.
 
@ton.yeung that would be annoying, yes
 
6:37 PM
@ton.yeung Oh, that'd be Ubisoft.
 
It's just a simple lobby ._.
Well, how would you do it?
On every update*?
That would cause a lot of "blinking" as the list reordered when a game drops off the list
That's true
I don't, I'm just pushing out the order Redis gives back
So as games are added and removed, I'm not sure if Redis would just completely shuffle
I don't really see a way around it
I'm polling redis, and pushing out non-full games
 
how do you merge two maps in JS?
 
mmkay
Game won't change on that list, game will only change in the "waiting room" (which hasn't been made yet)
Only the player count will change, along with a drop and push of full games and new games
mmkay
I may have to change how I'm displaying the list, but yeah
That's going to be tricky
Another way around that would be to just sort the data returned on the client side
Sort by fullest game
14/15 would display first
etc
 
@ssube I think it'd be: mergedMap = new Map(map1.entries().concat(map2.entries()))
 
@Retsam concat shouldn't work with an interator
 
6:44 PM
Well, the "poll" would be triggered by an action, not a set amount of time
 
unless that pulls the full array of results?
 
So a player joining/leaving a lobby, or a game being created would push changes
 
.entries() returns an array of key-value pairs.
 
Ok sweet, I'm going to revamp my lobby page real quick to get rid of that gross select box
 
6:46 PM
@ton.yeung and why they don't scale very well without some serious messaging abstraction
@ton.yeung lol, and that's why we hate hiring contractors
 
@ssube Whoops, skimmed that page the first time. Then new Map(Array.from(map1.entries()).concat(Array.from(map2.entries()))) would work, though it might not be the most efficient.
 
@Retsam yeah, I think deps.reduce((p, key) => p.set(c, deps[key]), new Map(this._deps)) is easier to read and probably faster
copy once, then set with reduce
 
!!afk Uhhh, shit.
 
@Trasiva what?
 
now how do I clean up this function:
constructor(...deps) {
  this._deps = deps[0] instanceof Map ? new Map(deps[0]) : new Map(deps);
}
 
6:50 PM
Is it possible to have a constant connection to a website, like you would with a real browser with PhantomJS? Trying to read data off a website 24/7, can't seem to keep the connection open. If I set the timeout really high, it will last as long as the timeout does and then dies. Thanks!
 
@antfuentes87 Welcome to the JavaScript chat! Please review the room rules. Please don'task if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@ton.yeung lol right
 
@CapricaSix I was! Just writing it out lol :)
 
@ssube Why allow them to provide an array of arrays if you're only going to look at the first array, anyway?
 
@ton.yeung No? Just want to have a active connection, like you would using a normal browser. There is a timer on the page, the timer counts down, just wanna read that timer, you are suppose to keep the page open 24/7 anyways... so I would not be doing anything, that you would not normally do with a browser.
 
6:54 PM
@Retsam it can accept either a map or multiple arguments that get get converted to a map, right? or am i reading that wrong.
 
@ton.yeung I don't think so, just hard to explain haha :(
 
@KevinB Ah. Yeah, I think you're right.
 
@SterlingArcher You've been requested to join the SOCVR room by user @Drew.
 
Yo 17
 
@antfuentes87 it's just explained poorly. You don't want to keep an active connection, you just want phantomjs to keep the client-side code executing and updating the page it is rendering, which i don't think it can do.
You'd be better off re-implementing that functionality with your own code, possibly even leaving phantomjs out of the loop.
 

« first day (1941 days earlier)      last day (3005 days later) »