-
Notifications
You must be signed in to change notification settings - Fork 2
Home
unwatch(prop, onUpdate) {
let i = (watchers[prop] || []).findIndex(f => f === onUpdate);
if (i === -1) {
throw new Error();
}
watchers.splice(i, 1);
}
Sophisticated user listing:
<p data-title="joinText list.authors ', ' map 'name'">
<span class="fa fa-pencil"></span>
<span data-content="join list.authors 'user' ', ' 3">
<template><micro-user></micro-user></template>
<template data-name="overflow">
+ <span data-content="sub list.authors.length 3"></span>
</template>
</span>
</p>
Switch:
<span data-content="switch user.role 'user' 'staff'">
<template><button>User action</button></template>
<template><button>Staff action</button></template>
<template>Nothing to do</template>
</span>
<span data-content="switch user.staff true">
<template><button>Staff action</button></template>
</span>
Format:
<span data-content="format 'Hello {user}!' 'user' user.name">
<span data-content="format 'Hello {user}!'">
<template name="user"><micro-user data-user="user"></micro-user></template>
</span>
Translate (calls format):
<span data-content="translate 'hello' 'user' user.name">
Advanced translation example:
<p>
<span data-content="translateEditedBy list.authors">
<template data-name="authors">
<span data-content="join list.authors 'user' ', ' 3">
<template><micro-user></micro-user></template>
</span>
</template>
</span>
</p>
<script>
this.data.translateEditedBy = (ctx, authors) => {
let n = authors.length;
return micro.bind.translate(ctx, n > 3 ? "edited-by-overflow" : "edited-by", "n", n);
}
{
"edited-by": "edited by {authors}",
"edited-by-overflow": ["edited by {authors} and {n} other", "edited by {authors} and {n} others"]
}
</script>
- Python / JavaScript API:
- Breaking changes okay
- User decides update time
- Sometimes non-breaking changes are not possible or only with disproportionate effort:
- (JavaScript) Convert
<custom-element>
from/to<div is="custom-element">
(can only be registered once)
- (JavaScript) Convert
- Web API:
- Breaking changes only after deprecation period
- Service provider decides update time, user needs time to make adjustments
Idea for non-breaking update path for function signatures:
def foo(a, b):
# ...
# ->
def foo(a, x, b=None, __version__=1):
if __version__ == 1:
b, x = x, 'default'
else:
if b is None:
raise Error()
# ...
# ->
def foo(a, x, b, __version__=2):
# ...
Assume that micro introduces a new announcement feature with the following API:
- type
Announcement
- Attribute
Application.announcements
- DB key
announcements
- endpoint
/api/announcements
- page
/announcements
- ...
If an existing micro application already makes use of any of those names, this could lead to breaking behavior (e.g. micro code modifies Application.announcements
or posts to /api/announcements
and they have different, unexpected semantics).
How can we solve this? New features that involve the extendable API could be major releases. New features could be introduced behind a feature toggle with a minor release and enabled by default with a major release. DB keys could be prefixed with micro
.
Rules that may be worth considering:
- multiline-comment-style (ESLint 4.9)