Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/dyoPublic

Dyo is a JavaScript library for building user interfaces.

NotificationsYou must be signed in to change notification settings

dyo/dyo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dyo

A JavaScript library for building user interfaces.

CoverageSizeLicenceNPM

Installation

  • Use a Direct Download:<script src=dyo.js></script>
  • Use a CDN:<script src=unpkg.com/dyo></script>
  • Use NPM:npm install dyo --save

Documentation

Documentation can be findon the website.

See theGetting Started page for a quick overview.

The documentation is divided into several sections:

You can improve it by sending pull requests tothis repository.

Examples

Several examples can be foundon the website. Here's one to get started:

import{h,render}from'dyo'functionExample(props){returnh('h1',{},'Hello ',props.name)}render(h(Example,{name:'World'}),'body')

This will render a heading element with the text content "Hello World" into the specified target(the body element).

Comparison

The library is much alike React, so it's only natural that a comparison of the differences is in order; Which if successful might manage to highlight why it exists.

Re-parenting

ThePortal component supports string selectors as targets. This presents an array of different possibilities with regards to isomorphic target references.

functionExample(props){returnh(Portal,{target:'main'},'Hello')}render(h(Example),'body')

In addition to this – re-parenting is baked into portals. That is when a portals container is changed, instead of unmounting its contents and re-mounting them to the newly designated container we can instead move its contents without replaying destruction unmount operations that may discard valuable interface and component state.

In co-ordination with custom renderers, portals afford the opportunity to create atomic branch specific custom renderers. Imagine isolated declarative canvas renderers within a document renderer.

Promises

Promises(or thenables) are first class values. This affords authors the ability to render promises, directly await promises within effects and events, and delay unmounting.

render(props=>Promise.resolve('Hello'),'body')functionExample(props){useEffect(async()=>{// out of band updates in here// are also batchedreturnasync()=>{// delays unmount until the animation// has completedreturnprops.current.animate({}).finished}})}

Callbacks

In an async world, public interfaces likerender are not guaranteed to complete synchronously if a subtree happens to have async dependencies within it. A consequence of this will see more use cases for the optionalcallback arguments that this function accepts – in much the same way authors are afforded the ability to await on this central routine.

awaitrender(props=>Promise.resolve('Hello'),'body')
Resources

In addition to otherhooks, a resource allocation hook that can be used to fetch and cache resources.

functionExample(props){constresource=useResource(props=>fetch('https://reqres.in/api/users'))returnh('pre',{},JSON.stringify(resource))}
Async Server Rendering

Server side rendering supports the plethora of async primitives supported.

import{http}from'http'import{h,render,useResource}from'dyo'functionExample(props){constresource=useResource(props=>fetch('https://reqres.in/api/users'))returnh('pre',{},JSON.stringify(resource))}http.createServer((request,response)=>{returnrender(h('html',{},h(Example)),response)}).listen(8080)

License

Dyo isMIT licensed.

About

Dyo is a JavaScript library for building user interfaces.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors9


[8]ページ先頭

©2009-2025 Movatter.jp