by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Austin Wright
@awwright
left-pad is just the gift that keeps on giving
dwhitney
@dwhitney
anybody know if there is a repo for typescript type declarations for the three different specs on https://rdf.js.org/
I don't see them but I thought I'd check
dwhitney
@dwhitney
thanks
elf Pavlik
@elf-pavlik
np
Arne Hassel
@megoth_twitter
huh, shouldn’t rdflib be listed in Libraries at https://rdf.js.org/ ? or am I just blind =P
elf Pavlik
@elf-pavlik
@megoth_twitter I don't know which interfaces it implements, would you like to make quick PR ?
Arne Hassel
@megoth_twitter
ah, that’s a good point, unsure about the specifics about that myself
elf Pavlik
@elf-pavlik
it think at least DataFactory, initial listing could include just that
Arne Hassel
@megoth_twitter
I added a PR to add rdflib.js to the list: rdfjs/rdfjs.github.io#5
it does not implement any of the specifications, but I think it’s important to have there anyway
Austin Wright
@awwright
Why does Data Model specify a DataFactory interface when WebIDL has a standard way of exposing constructors and object factories?
Thomas Bergwinkl
@bergos
@awwright where in the spec are factories defined?
Austin Wright
@awwright
@bergos The whole DataFactory interface, what's that doing that you can't with a WebIDL constructor?
Thomas Bergwinkl
@bergos
where in the webidl spec are factories defined?
if it's about using factory vs. using constructor, i think there is an older issues or log from a call.
Austin Wright
@awwright
Well WebIDL doesn't specify the term "factory" but in the sense of "something you call to create a new instance" there's definitely a standard way to do that; I can't find any other specification that defines any sort of "${thing}Factory" the way Data Model or Dataset does
Austin Wright
@awwright
Like one of the peculiarities is all of the interfaces have the same definition; so if the intention is that an implementation is going to expose the DataFactory, it's also going to have to expose Term, NamedNode, ect; because you have to explicitly hide interfaces with [NoInterfaceObject] (and even then that's highly discouraged)
victor felder
@vhf
The way I see DataFactory is as a utility. I think we could live without but I also think it's often useful to have this object you can pass around.
@awwright If I understand correctly you are saying two things:
  1. Why do we need DataFactory / why is it spec'd that way?
  2. Why isn't [Constructor] used for the interfaces 2.1 to 2.7?
Austin Wright
@awwright
@vhf Yeah; I'm not a huge expert but it definitely appears to diverge from what I would expect an interface to define
And I say that because... my implementation didn't implement the factory interface until recently: https://github.com/awwright/node-rdf (and it's still unpublished to npm), I've always expected people to call new Interface directly
elf Pavlik
@elf-pavlik
@awwright please see https://github.com/rdfjs/stream-spec/pull/10/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR142
having one object to pass around works very well, how would you imagine to do that with bunch of constructors?
Austin Wright
@awwright
@elf-pavlik Would that be a kind of dependency injection?
My suggestion would just be to have an optional parameter with an object of the interfaces; this would default to window (for Web browsers; and would be supplied with a module reference for Node.js etc.)
Tomasz Pluskiewicz
@tpluscode

default to window

I don't think it's a good idea to rely on the window object

Austin Wright
@awwright
Well that's not really our call to make, that's just how WebIDL works
elf Pavlik
@elf-pavlik
with native ES modules in all browser I also would not depend on any globals which didn't ship with the browser
@awwright what do you mean by 'object of the interfaces'
Austin Wright
@awwright
Or maybe "object of the constructors"... Right now the factory has lowercased function names for camelcased interfaces
Perhaps we can solicit some advice on how to define standard interfaces in ECMAScript modules & Node.js modules
elf Pavlik
@elf-pavlik
what advantage do you see in having constructors over having factories ?
Austin Wright
@awwright
@elf-pavlik Certainly there's different ways to do it, my implementation is specifically designed so you can use RDF as a native built-in of the application; comparable to DOM API support
elf Pavlik
@elf-pavlik
and how current DataFactory definition affects how your implementation works together with other modules implementing RDFJS interfaces ?
Austin Wright
@awwright
@elf-pavlik I'm not sure exactly the technical advantages but alignment with other specifications would be nice
victor felder
@vhf
What other specifications are you thinking about? Examples would help (me) understand what you suggest and why
elf Pavlik
@elf-pavlik
@awwright does your implementation allow applications using it to provide it with factory of their choice ?
Austin Wright
@awwright
Like if I do require('rdf') I should get a module with NamedNode, etc functions
And I can pass this as an option for dependency injection
elf Pavlik
@elf-pavlik
now one can do const factory = require('@rdfjs/data-model') and pass factory around
Austin Wright
@awwright
@vhf Any specification that uses WebIDL... DOM API, IndexedDB, WebSockets API, WebRTC API, Bluetooth, ...
elf Pavlik
@elf-pavlik
only difference seems with how one would use that 'object of the interfaces'
factory.namedNode('https://foo.example') vs new rdfjs.NamedNode('https://foo.example')
victor felder
@vhf
(you could even const {namedNode} = require('@rdfjs/data-model') and not use the factory object)
Austin Wright
@awwright
@elf-pavlik Well typically if you call a constructor as a function it returns a new instance of itself; String("foo") is functionally the same as new String("foo")
victor felder
@vhf
Looking at https://www.w3.org/TR/IndexedDB-2/#factory-interface , the fundamental difference is that IndexedDB is supposed to be implemented by browsers (it's a browser API, not a JS one), that's why it's accessible on window. I might be missing your point though
Austin Wright
@awwright
Though personally, I prefer the new form because it's more transparent to the developer about what's going on (it's probably going to generate a new instance of that interface)
victor felder
@vhf
Note that new String('foo') and String('foo') are different
elf Pavlik
@elf-pavlik
store.match(null, null, new NamedNode('https://foo.example/bar'))
vs
store.match(null, null, namedNode('https://foo.example/bar'))