HydraCG / Specifications

Specifications created by the Hydra W3C Community Group
Other
139 stars 25 forks source link

Callback based handling of responses #138

Closed asbjornu closed 7 years ago

asbjornu commented 7 years ago

In https://github.com/HydraCG/Specifications/pull/132#issuecomment-323815173 @alien-mcl writes:

Tha major issue I've got with getCollection is that the client need's to know ad-hoc that the result is a collection.

I agree that this is an issue. To decouple the request from the response, wouldn't a better design be to handle all responses through a callback instead? Then the request will just follow links in a completely generic way and it's up to the response callback handler to understand the context and how to deal with the different response types.

Thoughts?

elf-pavlik commented 7 years ago

If definition of hydra:collection property includes statement hydra:collection rdfs:range hydra:Collection client can expect an instance of a collection.

BTW I think this issue fits https://github.com/HydraCG/Heracles.ts since I suggested getCollection() method as an interface which could decorate an instance of hydra:EntryPoint

asbjornu commented 7 years ago

Yes, but the definition is flexible. Even the ApiDocumentation isn't static. Hard coding getCollection() would therefore break if the following the link results in something that is not a collection.

RubenVerborgh commented 7 years ago

No callbacks please, promises :wink:

elf-pavlik commented 7 years ago

I really thing that discussion about interfaces specific to client implementation (getCollection()) belongs to the reference client implementation: https://github.com/HydraCG/Heracles.ts I wouldn't even mind removing client snippets from use cases and only keep information here about the data and HTTP usage. Heracles.ts could include documentation about all the interfaces it includes.

When it comes definition of hydra:collection, even if for whatever reason we would decide to use schema:rangeIncludes instead of rdfs:range in its definition. I think we should clearly state that it shouldn't get used to reference something which @type doesn't include hydra:Collection. Otherwise we should not call this property hydra:collection.

asbjornu commented 7 years ago

BTW I think this issue fits https://github.com/HydraCG/Heracles.ts since I suggested getCollection() method as an interface which could decorate an instance of hydra:EntryPoint

Of course, I only created this here because the discussion started in a PR in this repository. Sorry!

If I'm not mistaken, that's what @alien-mcl is already discussing in HydraCG/Heracles.ts#2, so I'll just add my thoughts there and will close this issue.