Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to use redux-saga with lets say Alt.js #347

Closed
DEllement opened this issue May 24, 2016 · 4 comments
Closed

Is it possible to use redux-saga with lets say Alt.js #347

DEllement opened this issue May 24, 2016 · 4 comments
Labels

Comments

@DEllement
Copy link

i see in all example related to redux-saga that it require a redux store in order to work.

is it possible to make it work without it, or do i have to adapt my AltStore to Redux Store.

Thanks

@DEllement DEllement changed the title Is it possible to use redux-saga with lets say with Alt.js Is it possible to use redux-saga with lets say Alt.js May 24, 2016
@slorber
Copy link
Contributor

slorber commented May 24, 2016

@DEllement yes it is

I've just twitted about it because probably others could be interested.

https://twitter.com/sebastienlorber/status/735037978377105408
https://gist.github.com/slorber/c095671a14b2eccf8ad665a97a7b8ad1

@DEllement
Copy link
Author

Thanks @slorber for sharing your code, very apreciated 👍

@DEllement
Copy link
Author

DEllement commented May 25, 2016

So here was the solution for AltJs

import alt from './alt';
import { runSaga }  from 'redux-saga';
import rootSaga from './app/sagas';
var AppStore = require('./app/stores/AppStore');

const reduxSagaIO = {
    dispatch: events => alt.dispatch(events),
    subscribe: listener => {
        const callback = (events) => {
            //console.log(events.type, events);
            listener(events);
        }
        const callbackId = alt.dispatcher.register(callback);
        return () => alt.dispatcher.unregister(callbackId )
    },
    getState: () => AppStore.getState //AppStore is my main AltJs Store instance
}

runSaga(rootSaga(), reduxSagaIO);

@slorber
Copy link
Contributor

slorber commented May 25, 2016

NP.

I've backlinked the link in my gist for users interest to use Alt :)

@yelouafi yelouafi closed this as completed Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants