Reputation: 4814
I've seen it in a number of JavaScript libraries (eg. transducers-js, routex and redux). I'm supposing it's a form of namespacing, but I couldn't find an explanation or at least a comment about it anywhere.
Upvotes: 6
Views: 381
Reputation: 2462
"@@/" are the user-land, domain specific analogs of well-known symbols.
Generally, "@@/" are formatted as "@@$NAMESPACE/$property"
, where $NAMESPACE
is some domain identifier and $property
is a property of that domain.
"@@/" are not exactly well-known symbols because, for one, they are strings; nor are they part of the spec referenced in that question. "@@/" do resemble well-known symbols @@
in that they both effect domain-specific behavior. The domain for @@
is "all Code Realms" == "all instances of a JavaScript environment" == pretty much everything. The domain for "@@/" is NAMESPACE
.
Here is a comparison of the usage of "@@/" between transducers.js, routex, and redux
transducers.js - transducer implementation in JavaScript
{
"@@transducer/init": () => {...},
"@@transducer/result": (result) => {...},
"@@transducer/step": (result, input) => {...},
}
You can implement "@@/" methods here to conform to the transducers.js transformer protocol. If an object conforms to the transformer protocol, it is composable with other objects that conform to this protocol in order to conform to yet another protocol: the transducers.js transducer protocol.
routex - simple router for redux
export const ROUTE_CHANGE_START = '@@ROUTEX/ROUTE_CHANGE_START';
export const ROUTE_CHANGE_SUCCESS = '@@ROUTEX/ROUTE_CHANGE_SUCCESS';
export const ROUTE_CHANGE_FAIL = '@@ROUTEX/ROUTE_CHANGE_FAIL';
export const ROUTE_NOT_FOUND = '@@ROUTEX/ROUTE_NOT_FOUND';
export const TRANSITION_TO = '@@ROUTEX/TRANSITION_TO';
routex uses "@@/" as constants. They appear on the type
field of the exported actions of this router's actions.js
. They are used to implement reducer, exported for use with redux
and your own state + action reducers
redux - manages state for JavaScript applications
const ActionTypes = {
INIT: `@@redux/INIT${randomString()}`,
REPLACE: `@@redux/REPLACE${randomString()}`,
PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
}
redux uses "@@/" as constants as well; each of these is used to validate reducer shape. ActionTypes.INIT
is further used in combineReducers getUnexpectedStateShapeWarningMessage
to conditionally format the returned message. ActionTypes.REPLACE
was added in this pull request to handle an annoying warning message while validating reducer shape.
In short, these are all disparate cases of "@@/". transducers.js uses them to implement their transducer protocol, routex uses them as constants, and redux uses them to validate input. There's likely no single origin for them, though they may have drawn inspiration from @@
Upvotes: 1