X Tutup
The Wayback Machine - https://web.archive.org/web/20201211112337/https://github.com/simplcommerce/SimplCommerce/pull/675
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

Implemented real-time notification with signalR and Hangfire. #675

Merged
merged 32 commits into from Feb 3, 2019

Conversation

@Nongzhsh
Copy link
Contributor

@Nongzhsh Nongzhsh commented Dec 12, 2018

@thiennn Hi, i added the HangfireJobs module and Notifications module.
Please review it, then I will implement user notification management.
Looking forward to your reply.

Nongzhsh added 23 commits Aug 20, 2018
拉取上游更新
合并从源fork来的代码
同步上游
Added Farsi Language Localization (#671)
merge code from simplcommerce:master
merge code from simplcommerce:master
@thiennn
Copy link
Contributor

@thiennn thiennn commented Jan 20, 2019

@Nongzhsh sorry for the late response, I was super busy recently. There is too much code in this PR, it will take time to review :)

@Nongzhsh
Copy link
Contributor Author

@Nongzhsh Nongzhsh commented Jan 31, 2019

@thiennn Hi, I have synced the latest code and solved the conflict. Can you take a moment to check it? Thank you very much.

@thiennn
Copy link
Contributor

@thiennn thiennn commented Feb 2, 2019

@Nongzhsh Can we move the RealTime folder in Core to a separate module? I think we should keep the Core module thin

@Nongzhsh
Copy link
Contributor Author

@Nongzhsh Nongzhsh commented Feb 2, 2019

@thiennn Okay, got it. We can refactor it.

@Nongzhsh
Copy link
Contributor Author

@Nongzhsh Nongzhsh commented Feb 2, 2019

We should handle the notifications events (send and received events) on the client.

We can use https://github.com/bcerati/js-event-bus

@thiennn thiennn merged commit ade3b3e into simplcommerce:master Feb 3, 2019
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
simplcommerce.SimplCommerce Build #20190202.2 succeeded
Details
@afernandes
Copy link
Contributor

@afernandes afernandes commented Mar 7, 2019

We should handle the notifications events (send and received events) on the client.

We can use https://github.com/bcerati/js-event-bus

event bus basic

<html>
<head>
    <script>
        var simplCommerce = simplCommerce || {};

        /* SIMPLE EVENT BUS *****************************************/

        simplCommerce.event = (function () {

            var _callbacks = {};

            var on = function (eventName, callback) {
                if (!_callbacks[eventName]) {
                    _callbacks[eventName] = [];
                }

                _callbacks[eventName].push(callback);
            };

            var off = function (eventName, callback) {
                var callbacks = _callbacks[eventName];
                if (!callbacks) {
                    return;
                }

                var index = -1;
                for (var i = 0; i < callbacks.length; i++) {
                    if (callbacks[i] === callback) {
                        index = i;
                        break;
                    }
                }

                if (index < 0) {
                    return;
                }

                _callbacks[eventName].splice(index, 1);
            };

            var trigger = function (eventName) {
                var callbacks = _callbacks[eventName];
                if (!callbacks || !callbacks.length) {
                    return;
                }

                var args = Array.prototype.slice.call(arguments, 1);
                for (var i = 0; i < callbacks.length; i++) {
                    callbacks[i].apply(this, args);
                }
            };

            // Public interface ///////////////////////////////////////////////////

            return {
                on: on,
                off: off,
                trigger: trigger
            };
        })();
    </script>
</head>
<body>

    <button id="btnTest" onclick="javascript:btnTest_click();">Test</button>

    <script>
        simplCommerce.event.on('simplCommerce.init', function (notification) {
            alert(notification);
        });

        simplCommerce.event.on('simplCommerce.init', function (notification) {
            alert(notification + ' ok');
        });

        var btnTest_click = function(){
           simplCommerce.event.trigger('simplCommerce.init', 'test 123');
        }
    </script>
</body>

</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.
X Tutup