alloc / ople Goto Github PK
View Code? Open in Web Editor NEWEvent-driven, observable data flow for React ๐ฅ๐
Event-driven, observable data flow for React ๐ฅ๐
Currently, the useOple
hook does not support Concurrent mode. (The useEvents
hook does though)
Ople objects should be able to detach all their effects, but then reattach them at a later point. This will allow useOple
to wait until the "commit phase" (eg: when useEffect
is called) before receiving events and enabling reactions.
It would be great to be able to fire an event or function when an Ople object is disposed. Is this possible?
When an object is created with createOple
while inside another createOple
call, the parent object will be given ownership of the nested object. When the parent is disposed, the nested object will be, too.
When a function is passed, use it in an initOple
call. This would only be useful when doing new Ople
directly, as an alternative to createOple
.
Not sure if this is that useful, since OpleObject
s are deep readonly (in TypeScript world) outside their constructor already.
But I'll keep this issue open to gauge interest. It would be useful for JavaScript users, I suppose.
Is there a useEvents
function for use outside of react?
I'm not sure if should sit in the realm of the user, and possibly has performance implications, but for my use case, I would typically like to fire an event each time an Ople object's property / attribute changes (and create / dispose events). Without it a find myself subscribing to changes using wana
and it might be nicer to have it built into Ople
- should be easy to automate regardless so no biggie.
Events are not supposed to be emitted outside the constructor scope.
If you need external side effects, expose a method on your OpleObject
with the set
function.
This prevents a whole class of errors where you accidentally emit an event when you're supposed to call a method instead.
I'm rebuilding the standard redux todo-mvc in Ople here https://codesandbox.io/s/todomvc-8fb7u
And I'm at a point where I need to update react components on change.
What's the recommended approach for this?
Is it by emitting and listening to events with useEvents
?
Or is there some sort useAuto
like function, similar to wana
? (It doesn't seem like I can use wana's withAuto)
Are Ople
objects observable? Maybe I'm just assuming that because I know it's built on wana
.
What does set()
do? (Apologies for all the questions, please take your time to respond)
ie. Why should I be doing this?
constructor(props) {
super()
initOple(this, (self, set, emit) => {
set(props)
})
}
const Todo = createClass(
'Todo',
props => (todo, set, emit) => {
set(props)
}
)
instead of this?
constructor(props) {
super()
Object.keys(props).forEach(p => this[p] = props[p])
initOple(this, (self, set, emit) => {
// ...
})
}
const Todo = createClass(
'Todo',
props => (todo, set, emit) => {
...props
}
)
Only methods defined with the set
function are wrapped with no
(which disables observation) and withOple
(which sets the Ople context). In a future version, when an Ople
subclass is first constructed, the Ople
constructor will search the prototype chain for methods to wrap.
Is there a way to listen to all events, regardless of the source? I suppose you would also want to emit the source with the event in that case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.