Giter Club home page Giter Club logo

duix's People

Contributors

brodanoel avatar dependabot[bot] avatar jehon avatar teddygandon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

duix's Issues

Implement Events

Implement events. For example: "User just logged"

Should be implemented in some way like:

duix.event('USER_JUST_LOGGED'); // not sure if `duix.event` or `duix.dispatch`

duix.listen(‘USER_JUST_LOGGED’, callback);

Importing "index.js" in browser does not work

By importing

import deepEqual from './utils/deepEqual';

The import does not work in browser, because the extension is not set.

Use instead:

import deepEqual from './utils/deepEqual.js';

idea

const store = Object.create(null)

export default ((host = Object.create(null), subs = new Map()) => Object.assign(host, {
    emit(event, ...data) {
        if (subs.has(event)) for (const h of subs.get(event)) h.apply(null, data)
    },
    subscribe(event, handler) {
        if (!(handler instanceof Function)) throw new TypeError('subs need functions')
        if (!subs.has(event)) subs.set(event, new Set())
        subs.get(event).add(handler)
        return () => host.unsubscribe(event, handler)
    },
    unsubscribe (event, handler) {
        if (!subs.has(event)) return
        const ls = subs.get(event)
        ls.delete(handler)
        if (!ls.size) subs.delete(event)
    },
    set(key, val) {
        const old = store[key]
        if (old != null && old === val) return
        host.emit(key, store[key] = val, old)
    },
    get: key => store[key]
}))()

DUIX doesn't work in React with Hooks

If you are doing:

useEffect(() => {
  duix.subscribe('user', setUser)
}, []);

The setUser function is going to get old in the following render.
We have to find a way to keep it simple, but fix it.

I think we should not create a useDuix(), because the idea is to keep DUIX as a state manager based on events.

Should have an automated test

Would travis be ok for you?

=> If yes, I can implement it, but you need to enable the integration
If no, tell me which one to use :-)

Add TypeScript doc files

Example from Expo

build.d.ts

declare enum BackgroundFetchResult {
    NoData = 1,
    NewData = 2,
    Failed = 3
}
declare enum BackgroundFetchStatus {
    Denied = 1,
    Restricted = 2,
    Available = 3
}
interface BackgroundFetchOptions {
    minimumInterval?: number;
    stopOnTerminate?: boolean;
    startOnBoot?: boolean;
}
export declare function getStatusAsync(): Promise<BackgroundFetchStatus | null>;
export declare function setMinimumIntervalAsync(minimumInterval: number): Promise<void>;
export declare function registerTaskAsync(taskName: string, options?: BackgroundFetchOptions): Promise<void>;
export declare function unregisterTaskAsync(taskName: string): Promise<void>;
export { BackgroundFetchResult as Result, BackgroundFetchStatus as Status, };

Inmutable?

Check what happens if we mutate the state. And define what should happens (should it be immutable?)

For example:
‘’’js
const x = duix.get(‘x’);
x.foo = ‘bar’;
‘’’

Document it

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.